<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><link rel="stylesheet" type="text/css" href="style.css" /><script type="text/javascript" src="highlight.js"></script></head><body><pre><span class="hs-pragma">{-# LANGUAGE DeriveDataTypeable #-}</span><span>
</span><span id="line-2"></span><span class="hs-pragma">{-# LANGUAGE DeriveGeneric #-}</span><span>
</span><span id="line-3"></span><span class="hs-pragma">{-# LANGUAGE FlexibleContexts #-}</span><span>
</span><span id="line-4"></span><span class="hs-pragma">{-# LANGUAGE FlexibleInstances #-}</span><span>
</span><span id="line-5"></span><span>
</span><span id="line-6"></span><span class="hs-comment">-----------------------------------------------------------------------------</span><span>
</span><span id="line-7"></span><span class="hs-comment">-- |</span><span>
</span><span id="line-8"></span><span class="hs-comment">-- Module      :  Distribution.Simple.PackageIndex</span><span>
</span><span id="line-9"></span><span class="hs-comment">-- Copyright   :  (c) David Himmelstrup 2005,</span><span>
</span><span id="line-10"></span><span class="hs-comment">--                    Bjorn Bringert 2007,</span><span>
</span><span id="line-11"></span><span class="hs-comment">--                    Duncan Coutts 2008-2009</span><span>
</span><span id="line-12"></span><span class="hs-comment">--</span><span>
</span><span id="line-13"></span><span class="hs-comment">-- Maintainer  :  cabal-devel@haskell.org</span><span>
</span><span id="line-14"></span><span class="hs-comment">-- Portability :  portable</span><span>
</span><span id="line-15"></span><span class="hs-comment">--</span><span>
</span><span id="line-16"></span><span class="hs-comment">-- An index of packages whose primary key is 'UnitId'.  Public libraries</span><span>
</span><span id="line-17"></span><span class="hs-comment">-- are additionally indexed by 'PackageName' and 'Version'.</span><span>
</span><span id="line-18"></span><span class="hs-comment">-- Technically, these are an index of *units* (so we should eventually</span><span>
</span><span id="line-19"></span><span class="hs-comment">-- rename it to 'UnitIndex'); but in the absence of internal libraries</span><span>
</span><span id="line-20"></span><span class="hs-comment">-- or Backpack each unit is equivalent to a package.</span><span>
</span><span id="line-21"></span><span class="hs-comment">--</span><span>
</span><span id="line-22"></span><span class="hs-comment">-- While 'PackageIndex' is parametric over what it actually records,</span><span>
</span><span id="line-23"></span><span class="hs-comment">-- it is in fact only ever instantiated with a single element:</span><span>
</span><span id="line-24"></span><span class="hs-comment">-- The 'InstalledPackageIndex' (defined here) contains a graph of</span><span>
</span><span id="line-25"></span><span class="hs-comment">-- 'InstalledPackageInfo's representing the packages in a</span><span>
</span><span id="line-26"></span><span class="hs-comment">-- package database stack.  It is used in a variety of ways:</span><span>
</span><span id="line-27"></span><span class="hs-comment">--</span><span>
</span><span id="line-28"></span><span class="hs-comment">--   * The primary use to let Cabal access the same installed</span><span>
</span><span id="line-29"></span><span class="hs-comment">--     package database which is used by GHC during compilation.</span><span>
</span><span id="line-30"></span><span class="hs-comment">--     For example, this data structure is used by 'ghc-pkg'</span><span>
</span><span id="line-31"></span><span class="hs-comment">--     and 'Cabal' to do consistency checks on the database</span><span>
</span><span id="line-32"></span><span class="hs-comment">--     (are the references closed).</span><span>
</span><span id="line-33"></span><span class="hs-comment">--</span><span>
</span><span id="line-34"></span><span class="hs-comment">--   * Given a set of dependencies, we can compute the transitive</span><span>
</span><span id="line-35"></span><span class="hs-comment">--     closure of dependencies.  This is to check if the versions</span><span>
</span><span id="line-36"></span><span class="hs-comment">--     of packages are consistent, and also needed by multiple</span><span>
</span><span id="line-37"></span><span class="hs-comment">--     tools (Haddock must be explicitly told about the every</span><span>
</span><span id="line-38"></span><span class="hs-comment">--     transitive package to do cross-package linking;</span><span>
</span><span id="line-39"></span><span class="hs-comment">--     preprocessors must know about the include paths of all</span><span>
</span><span id="line-40"></span><span class="hs-comment">--     transitive dependencies.)</span><span>
</span><span id="line-41"></span><span class="hs-comment">--</span><span>
</span><span id="line-42"></span><span class="hs-comment">-- This 'PackageIndex' is NOT to be confused with</span><span>
</span><span id="line-43"></span><span class="hs-comment">-- 'Distribution.Client.PackageIndex', which indexes packages only by</span><span>
</span><span id="line-44"></span><span class="hs-comment">-- 'PackageName' (this makes it suitable for indexing source packages,</span><span>
</span><span id="line-45"></span><span class="hs-comment">-- for which we don't know 'UnitId's.)</span><span>
</span><span id="line-46"></span><span class="hs-comment">--</span><span>
</span><span id="line-47"></span><span class="hs-keyword">module</span><span> </span><span class="hs-identifier">Distribution.Simple.PackageIndex</span><span> </span><span class="hs-special">(</span><span>
</span><span id="line-48"></span><span>  </span><span class="annot"><span class="hs-comment">-- * Package index data type</span></span><span>
</span><span id="line-49"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier">InstalledPackageIndex</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-50"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier">PackageIndex</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-51"></span><span>
</span><span id="line-52"></span><span>  </span><span class="annot"><span class="hs-comment">-- * Creating an index</span></span><span>
</span><span id="line-53"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#fromList"><span class="hs-identifier">fromList</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-54"></span><span>
</span><span id="line-55"></span><span>  </span><span class="annot"><span class="hs-comment">-- * Updates</span></span><span>
</span><span id="line-56"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#merge"><span class="hs-identifier">merge</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-57"></span><span>
</span><span id="line-58"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#insert"><span class="hs-identifier">insert</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-59"></span><span>
</span><span id="line-60"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deleteUnitId"><span class="hs-identifier">deleteUnitId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-61"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deleteSourcePackageId"><span class="hs-identifier">deleteSourcePackageId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-62"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deletePackageName"><span class="hs-identifier">deletePackageName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-63"></span><span class="hs-comment">--  deleteDependency,</span><span>
</span><span id="line-64"></span><span>
</span><span id="line-65"></span><span>  </span><span class="annot"><span class="hs-comment">-- * Queries</span></span><span>
</span><span id="line-66"></span><span>
</span><span id="line-67"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Precise lookups</span></span><span>
</span><span id="line-68"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier">lookupUnitId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-69"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupComponentId"><span class="hs-identifier">lookupComponentId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-70"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupSourcePackageId"><span class="hs-identifier">lookupSourcePackageId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-71"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupPackageId"><span class="hs-identifier">lookupPackageId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-72"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupPackageName"><span class="hs-identifier">lookupPackageName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-73"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupDependency"><span class="hs-identifier">lookupDependency</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-74"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupInternalDependency"><span class="hs-identifier">lookupInternalDependency</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-75"></span><span>
</span><span id="line-76"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Case-insensitive searches</span></span><span>
</span><span id="line-77"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchByName"><span class="hs-identifier">searchByName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-78"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#SearchResult"><span class="hs-identifier">SearchResult</span></a></span><span class="hs-special">(</span><span class="hs-glyph">..</span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-79"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchByNameSubstring"><span class="hs-identifier">searchByNameSubstring</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-80"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchWithPredicate"><span class="hs-identifier">searchWithPredicate</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-81"></span><span>
</span><span id="line-82"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Bulk queries</span></span><span>
</span><span id="line-83"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier">allPackages</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-84"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesByName"><span class="hs-identifier">allPackagesByName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-85"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageId"><span class="hs-identifier">allPackagesBySourcePackageId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-86"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageIdAndLibName"><span class="hs-identifier">allPackagesBySourcePackageIdAndLibName</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-87"></span><span>
</span><span id="line-88"></span><span>  </span><span class="annot"><span class="hs-comment">-- ** Special queries</span></span><span>
</span><span id="line-89"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#brokenPackages"><span class="hs-identifier">brokenPackages</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-90"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyClosure"><span class="hs-identifier">dependencyClosure</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-91"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#reverseDependencyClosure"><span class="hs-identifier">reverseDependencyClosure</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-92"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#topologicalOrder"><span class="hs-identifier">topologicalOrder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-93"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#reverseTopologicalOrder"><span class="hs-identifier">reverseTopologicalOrder</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-94"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyInconsistencies"><span class="hs-identifier">dependencyInconsistencies</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-95"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyCycles"><span class="hs-identifier">dependencyCycles</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-96"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier">dependencyGraph</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-97"></span><span>  </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#moduleNameIndex"><span class="hs-identifier">moduleNameIndex</span></a></span><span>
</span><span id="line-98"></span><span>  </span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-99"></span><span>
</span><span id="line-100"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">)</span><span>
</span><span id="line-101"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Compat.Prelude.html"><span class="hs-identifier">Distribution.Compat.Prelude</span></a></span><span> </span><span class="hs-keyword">hiding</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.List.html#lookup"><span class="hs-identifier">lookup</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-102"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Strict.html#"><span class="hs-identifier">Data.Map.Strict</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Map</span></span><span>
</span><span id="line-103"></span><span>
</span><span id="line-104"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Package.html"><span class="hs-identifier">Distribution.Package</span></a></span><span>
</span><span id="line-105"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Backpack.html"><span class="hs-identifier">Distribution.Backpack</span></a></span><span>
</span><span id="line-106"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.ModuleName.html"><span class="hs-identifier">Distribution.ModuleName</span></a></span><span>
</span><span id="line-107"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="Distribution.InstalledPackageInfo.html"><span class="hs-identifier">Distribution.InstalledPackageInfo</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">IPI</span></span><span>
</span><span id="line-108"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Version.html"><span class="hs-identifier">Distribution.Version</span></a></span><span>
</span><span id="line-109"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Simple.Utils.html"><span class="hs-identifier">Distribution.Simple.Utils</span></a></span><span>
</span><span id="line-110"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html"><span class="hs-identifier">Distribution.Types.LibraryName</span></a></span><span>
</span><span id="line-111"></span><span>
</span><span id="line-112"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Exception.html#"><span class="hs-identifier">Control.Exception</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier">assert</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-113"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.html#"><span class="hs-identifier">Data.Array</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Arr.html#%21"><span class="hs-operator">(!)</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-114"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../array/src/Data.Array.html#"><span class="hs-identifier">Data.Array</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Array</span></span><span>
</span><span id="line-115"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#"><span class="hs-identifier">Data.Graph</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Graph</span></span><span>
</span><span id="line-116"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Data.List.html#"><span class="hs-identifier">Data.List</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">List</span></span><span> </span><span class="hs-special">(</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#groupBy"><span class="hs-identifier">groupBy</span></a></span><span class="hs-special">,</span><span>  </span><span class="annot"><a href="../../base/src/Data.OldList.html#deleteBy"><span class="hs-identifier">deleteBy</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.OldList.html#deleteFirstsBy"><span class="hs-identifier">deleteFirstsBy</span></a></span><span> </span><span class="hs-special">)</span><span>
</span><span id="line-117"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Data.List.NonEmpty.html#"><span class="hs-identifier">Data.List.NonEmpty</span></a></span><span> </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">NE</span></span><span>
</span><span id="line-118"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../containers/src/Data.Tree.html#"><span class="hs-identifier">Data.Tree</span></a></span><span>  </span><span class="hs-keyword">as</span><span> </span><span class="annot"><span class="hs-identifier">Tree</span></span><span>
</span><span id="line-119"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="../../base/src/Control.Monad.html#"><span class="hs-identifier">Control.Monad</span></a></span><span>
</span><span id="line-120"></span><span class="hs-keyword">import</span><span> </span><span class="annot"><a href="Distribution.Compat.Stack.html"><span class="hs-identifier">Distribution.Compat.Stack</span></a></span><span>
</span><span id="line-121"></span><span>
</span><span id="line-122"></span><span class="hs-keyword">import</span><span> </span><span class="hs-keyword">qualified</span><span> </span><span class="annot"><a href="../../base/src/Prelude.html#"><span class="hs-identifier">Prelude</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/Data.Foldable.html#foldr1"><span class="hs-identifier">foldr1</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-123"></span><span>
</span><span id="line-124"></span><span class="hs-comment">-- | The collection of information about packages from one or more 'PackageDB's.</span><span>
</span><span id="line-125"></span><span class="hs-comment">-- These packages generally should have an instance of 'PackageInstalled'</span><span>
</span><span id="line-126"></span><span class="hs-comment">--</span><span>
</span><span id="line-127"></span><span class="hs-comment">-- Packages are uniquely identified in by their 'UnitId', they can</span><span>
</span><span id="line-128"></span><span class="hs-comment">-- also be efficiently looked up by package name or by name and version.</span><span>
</span><span id="line-129"></span><span class="hs-comment">--</span><span>
</span><span id="line-130"></span><span id="local-6989586621679707685"><span id="local-6989586621679707686"></span></span><span class="hs-keyword">data</span><span> </span><span id="PackageIndex"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-var">PackageIndex</span></a></span></span><span> </span><span id="local-6989586621679708137"><span class="annot"><a href="#local-6989586621679708137"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="PackageIndex"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-var">PackageIndex</span></a></span></span><span> </span><span class="hs-special">{</span><span>
</span><span id="line-131"></span><span>  </span><span class="hs-comment">-- The primary index. Each InstalledPackageInfo record is uniquely identified</span><span>
</span><span id="line-132"></span><span>  </span><span class="hs-comment">-- by its UnitId.</span><span>
</span><span id="line-133"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-134"></span><span>  </span><span id="unitIdIndex"><span class="annot"><span class="annottext">forall a. PackageIndex a -&gt; Map UnitId a
</span><a href="Distribution.Simple.PackageIndex.html#unitIdIndex"><span class="hs-identifier hs-var hs-var">unitIdIndex</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708137"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-135"></span><span>
</span><span id="line-136"></span><span>  </span><span class="hs-comment">-- This auxiliary index maps package names (case-sensitively) to all the</span><span>
</span><span id="line-137"></span><span>  </span><span class="hs-comment">-- versions and instances of that package. This allows us to find all</span><span>
</span><span id="line-138"></span><span>  </span><span class="hs-comment">-- versions satisfying a dependency.</span><span>
</span><span id="line-139"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-140"></span><span>  </span><span class="hs-comment">-- It is a three-level index. The first level is the package name,</span><span>
</span><span id="line-141"></span><span>  </span><span class="hs-comment">-- the second is the package version and the final level is instances</span><span>
</span><span id="line-142"></span><span>  </span><span class="hs-comment">-- of the same package version. These are unique by UnitId</span><span>
</span><span id="line-143"></span><span>  </span><span class="hs-comment">-- and are kept in preference order.</span><span>
</span><span id="line-144"></span><span>  </span><span class="hs-comment">--</span><span>
</span><span id="line-145"></span><span>  </span><span class="hs-comment">-- FIXME: Clarify what &quot;preference order&quot; means. Check that this invariant is</span><span>
</span><span id="line-146"></span><span>  </span><span class="hs-comment">-- preserved. See #1463 for discussion.</span><span>
</span><span id="line-147"></span><span>  </span><span id="packageIdIndex"><span class="annot"><span class="annottext">forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-glyph">!</span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html#LibraryName"><span class="hs-identifier hs-type">LibraryName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.Version.html#Version"><span class="hs-identifier hs-type">Version</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679708137"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-148"></span><span>
</span><span id="line-149"></span><span>  </span><span class="hs-special">}</span><span> </span><span class="hs-keyword">deriving</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707672"><span id="local-6989586621679707680"><span class="annot"><span class="annottext">PackageIndex a -&gt; PackageIndex a -&gt; Bool
(PackageIndex a -&gt; PackageIndex a -&gt; Bool)
-&gt; (PackageIndex a -&gt; PackageIndex a -&gt; Bool)
-&gt; Eq (PackageIndex a)
forall a. Eq a =&gt; PackageIndex a -&gt; PackageIndex a -&gt; Bool
forall a. (a -&gt; a -&gt; Bool) -&gt; (a -&gt; a -&gt; Bool) -&gt; Eq a
/= :: PackageIndex a -&gt; PackageIndex a -&gt; Bool
$c/= :: forall a. Eq a =&gt; PackageIndex a -&gt; PackageIndex a -&gt; Bool
== :: PackageIndex a -&gt; PackageIndex a -&gt; Bool
$c== :: forall a. Eq a =&gt; PackageIndex a -&gt; PackageIndex a -&gt; Bool
</span><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var">Eq</span></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">(forall x. PackageIndex a -&gt; Rep (PackageIndex a) x)
-&gt; (forall x. Rep (PackageIndex a) x -&gt; PackageIndex a)
-&gt; Generic (PackageIndex a)
forall x. Rep (PackageIndex a) x -&gt; PackageIndex a
forall x. PackageIndex a -&gt; Rep (PackageIndex a) x
forall a.
(forall x. a -&gt; Rep a x) -&gt; (forall x. Rep a x -&gt; a) -&gt; Generic a
forall a x. Rep (PackageIndex a) x -&gt; PackageIndex a
forall a x. PackageIndex a -&gt; Rep (PackageIndex a) x
$cto :: forall a x. Rep (PackageIndex a) x -&gt; PackageIndex a
$cfrom :: forall a x. PackageIndex a -&gt; Rep (PackageIndex a) x
</span><a href="../../base/src/GHC.Generics.html#Generic"><span class="hs-identifier hs-var hs-var hs-var hs-var">Generic</span></a></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707645"><span id="local-6989586621679707647"><span id="local-6989586621679707656"><span class="annot"><span class="annottext">Int -&gt; PackageIndex a -&gt; ShowS
[PackageIndex a] -&gt; ShowS
PackageIndex a -&gt; String
(Int -&gt; PackageIndex a -&gt; ShowS)
-&gt; (PackageIndex a -&gt; String)
-&gt; ([PackageIndex a] -&gt; ShowS)
-&gt; Show (PackageIndex a)
forall a. Show a =&gt; Int -&gt; PackageIndex a -&gt; ShowS
forall a. Show a =&gt; [PackageIndex a] -&gt; ShowS
forall a. Show a =&gt; PackageIndex a -&gt; String
forall a.
(Int -&gt; a -&gt; ShowS) -&gt; (a -&gt; String) -&gt; ([a] -&gt; ShowS) -&gt; Show a
showList :: [PackageIndex a] -&gt; ShowS
$cshowList :: forall a. Show a =&gt; [PackageIndex a] -&gt; ShowS
show :: PackageIndex a -&gt; String
$cshow :: forall a. Show a =&gt; PackageIndex a -&gt; String
showsPrec :: Int -&gt; PackageIndex a -&gt; ShowS
$cshowsPrec :: forall a. Show a =&gt; Int -&gt; PackageIndex a -&gt; ShowS
</span><a href="../../base/src/GHC.Show.html#Show"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Show</span></a></span></span></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707611"><span id="local-6989586621679707627"><span id="local-6989586621679707630"><span id="local-6989586621679707632"><span class="annot"><span class="annottext">ReadPrec [PackageIndex a]
ReadPrec (PackageIndex a)
Int -&gt; ReadS (PackageIndex a)
ReadS [PackageIndex a]
(Int -&gt; ReadS (PackageIndex a))
-&gt; ReadS [PackageIndex a]
-&gt; ReadPrec (PackageIndex a)
-&gt; ReadPrec [PackageIndex a]
-&gt; Read (PackageIndex a)
forall a. Read a =&gt; ReadPrec [PackageIndex a]
forall a. Read a =&gt; ReadPrec (PackageIndex a)
forall a. Read a =&gt; Int -&gt; ReadS (PackageIndex a)
forall a. Read a =&gt; ReadS [PackageIndex a]
forall a.
(Int -&gt; ReadS a)
-&gt; ReadS [a] -&gt; ReadPrec a -&gt; ReadPrec [a] -&gt; Read a
readListPrec :: ReadPrec [PackageIndex a]
$creadListPrec :: forall a. Read a =&gt; ReadPrec [PackageIndex a]
readPrec :: ReadPrec (PackageIndex a)
$creadPrec :: forall a. Read a =&gt; ReadPrec (PackageIndex a)
readList :: ReadS [PackageIndex a]
$creadList :: forall a. Read a =&gt; ReadS [PackageIndex a]
readsPrec :: Int -&gt; ReadS (PackageIndex a)
$creadsPrec :: forall a. Read a =&gt; Int -&gt; ReadS (PackageIndex a)
</span><a href="../../base/src/GHC.Read.html#Read"><span class="hs-identifier hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var hs-var">Read</span></a></span></span></span></span></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../base/src/Data.Typeable.Internal.html#Typeable"><span class="hs-identifier hs-type">Typeable</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-150"></span><span>
</span><span id="line-151"></span><span id="local-6989586621679708109"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679707593"><span id="local-6989586621679707595"><span id="local-6989586621679707597"><span class="annot"><a href="../../binary/src/Data.Binary.Class.html#Binary"><span class="hs-identifier hs-type">Binary</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708109"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="../../binary/src/Data.Binary.Class.html#Binary"><span class="hs-identifier hs-type">Binary</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708109"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span></span></span><span>
</span><span id="line-152"></span><span id="local-6989586621679708103"><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679707585"><span id="local-6989586621679707587"><span class="annot"><a href="Distribution.Utils.Structured.html#Structured"><span class="hs-identifier hs-type">Structured</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708103"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Utils.Structured.html#Structured"><span class="hs-identifier hs-type">Structured</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708103"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">)</span></span></span></span><span>
</span><span id="line-153"></span><span>
</span><span id="line-154"></span><span class="hs-comment">-- | The default package index which contains 'InstalledPackageInfo'.  Normally</span><span>
</span><span id="line-155"></span><span class="hs-comment">-- use this.</span><span>
</span><span id="line-156"></span><span class="hs-keyword">type</span><span> </span><span id="InstalledPackageIndex"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-var">InstalledPackageIndex</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span>
</span><span id="line-157"></span><span>
</span><span id="line-158"></span><span class="hs-keyword">instance</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#Monoid"><span class="hs-identifier hs-type">Monoid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-159"></span><span>  </span><span id="local-6989586621679707577"><span class="annot"><span class="annottext">mempty :: PackageIndex InstalledPackageInfo
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var hs-var hs-var hs-var">mempty</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
forall a.
Map UnitId a
-&gt; Map (PackageName, LibraryName) (Map Version [a])
-&gt; PackageIndex a
</span><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-var">PackageIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
forall k a. Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#empty"><span class="hs-identifier hs-var">Map.empty</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall k a. Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#empty"><span class="hs-identifier hs-var">Map.empty</span></a></span><span>
</span><span id="line-160"></span><span>  </span><span id="local-6989586621679707574"><span class="annot"><span class="annottext">mappend :: PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-identifier hs-var hs-var hs-var hs-var">mappend</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
forall a. Semigroup a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var">(&lt;&gt;)</span></a></span><span>
</span><span id="line-161"></span><span>  </span><span class="hs-comment">--save one mappend with empty in the common case:</span><span>
</span><span id="line-162"></span><span>  </span><span id="local-6989586621679707570"><span class="annot"><span class="annottext">mconcat :: [PackageIndex InstalledPackageInfo]
-&gt; PackageIndex InstalledPackageInfo
</span><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var hs-var hs-var hs-var">mconcat</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span>
</span><span id="line-163"></span><span>  </span><span class="annot"><a href="../../base/src/GHC.Base.html#mconcat"><span class="hs-identifier hs-var">mconcat</span></a></span><span> </span><span id="local-6989586621679707569"><span class="annot"><span class="annottext">[PackageIndex InstalledPackageInfo]
</span><a href="#local-6989586621679707569"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(PackageIndex InstalledPackageInfo
 -&gt; PackageIndex InstalledPackageInfo
 -&gt; PackageIndex InstalledPackageInfo)
-&gt; [PackageIndex InstalledPackageInfo]
-&gt; PackageIndex InstalledPackageInfo
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; a -&gt; a) -&gt; t a -&gt; a
</span><a href="../../base/src/Data.Foldable.html#foldr1"><span class="hs-identifier hs-var">Prelude.foldr1</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
forall a. Monoid a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#mappend"><span class="hs-identifier hs-var">mappend</span></a></span><span> </span><span class="annot"><span class="annottext">[PackageIndex InstalledPackageInfo]
</span><a href="#local-6989586621679707569"><span class="hs-identifier hs-var">xs</span></a></span><span>
</span><span id="line-164"></span><span>
</span><span id="line-165"></span><span class="hs-keyword">instance</span><span> </span><span id="local-6989586621679707564"><span id="local-6989586621679707566"><span class="annot"><a href="../../base/src/GHC.Base.html#Semigroup"><span class="hs-identifier hs-type">Semigroup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">)</span></span></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-166"></span><span>  </span><span id="local-6989586621679707562"><span class="annot"><span class="annottext">&lt;&gt; :: PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="../../base/src/GHC.Base.html#%3C%3E"><span class="hs-operator hs-var hs-var hs-var hs-var">(&lt;&gt;)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#merge"><span class="hs-identifier hs-var">merge</span></a></span><span>
</span><span id="line-167"></span><span>
</span><span id="line-168"></span><span class="hs-pragma">{-# NOINLINE</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#invariant"><span class="hs-pragma hs-type">invariant</span></a></span><span> </span><span class="hs-pragma">#-}</span><span>
</span><span id="line-169"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#invariant"><span class="hs-identifier hs-type">invariant</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Compat.Stack.html#WithCallStack"><span class="hs-identifier hs-type">WithCallStack</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span>
</span><span id="line-170"></span><span id="invariant"><span class="annot"><span class="annottext">invariant :: WithCallStack (PackageIndex InstalledPackageInfo -&gt; Bool)
</span><a href="Distribution.Simple.PackageIndex.html#invariant"><span class="hs-identifier hs-var hs-var">invariant</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707557"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707557"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707556"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707556"><span class="hs-identifier hs-var">pnames</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-171"></span><span>  </span><span class="hs-comment">-- trace (show pids' ++ &quot;\n&quot; ++ show pnames') $</span><span>
</span><span id="line-172"></span><span>  </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707555"><span class="hs-identifier hs-var">pids'</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId] -&gt; [UnitId] -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707554"><span class="hs-identifier hs-var">pnames'</span></a></span><span>
</span><span id="line-173"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-174"></span><span>  </span><span id="local-6989586621679707555"><span class="annot"><span class="annottext">pids' :: [UnitId]
</span><a href="#local-6989586621679707555"><span class="hs-identifier hs-var hs-var">pids'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; [InstalledPackageInfo] -&gt; [UnitId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo -&gt; [InstalledPackageInfo]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707557"><span class="hs-identifier hs-var">pids</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-175"></span><span>  </span><span id="local-6989586621679707554"><span class="annot"><span class="annottext">pnames' :: [UnitId]
</span><a href="#local-6989586621679707554"><span class="hs-identifier hs-var hs-var">pnames'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[UnitId] -&gt; [UnitId]
forall a. Ord a =&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sort"><span class="hs-identifier hs-var">sort</span></a></span><span>
</span><span id="line-176"></span><span>     </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; UnitId -&gt; UnitId
forall a. HasCallStack =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679707541"><span class="hs-identifier hs-var">pinstOk</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707540"><span class="hs-identifier hs-var">pinst</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-177"></span><span>     </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679707539"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707539"><span class="hs-identifier hs-var">pname</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707538"><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707538"><span class="hs-identifier hs-var">plib</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707537"><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707537"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; [((PackageName, LibraryName),
     Map Version [InstalledPackageInfo])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707556"><span class="hs-identifier hs-var">pnames</span></a></span><span>
</span><span id="line-178"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707535"><span class="annot"><span class="annottext">pversOk :: Bool
</span><a href="#local-6989586621679707535"><span class="hs-identifier hs-var hs-var">pversOk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo] -&gt; Bool
forall k a. Map k a -&gt; Bool
</span><a href="../../containers/src/Data.Map.Internal.html#null"><span class="hs-identifier hs-var">Map.null</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707537"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-179"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707532"><span class="annot"><span class="annottext">Version
</span><a href="#local-6989586621679707532"><span class="hs-identifier hs-var">pver</span></a></span></span><span class="hs-special">,</span><span>  </span><span id="local-6989586621679707531"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707531"><span class="hs-identifier hs-var">pinsts</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; [(Version, [InstalledPackageInfo])]
-&gt; [(Version, [InstalledPackageInfo])]
forall a. HasCallStack =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679707535"><span class="hs-identifier hs-var">pversOk</span></a></span><span> </span><span class="annot"><span class="annottext">([(Version, [InstalledPackageInfo])]
 -&gt; [(Version, [InstalledPackageInfo])])
-&gt; [(Version, [InstalledPackageInfo])]
-&gt; [(Version, [InstalledPackageInfo])]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
-&gt; [(Version, [InstalledPackageInfo])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707537"><span class="hs-identifier hs-var">pvers</span></a></span><span>
</span><span id="line-180"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707528"><span class="annot"><span class="annottext">pinsts' :: [InstalledPackageInfo]
</span><a href="#local-6989586621679707528"><span class="hs-identifier hs-var hs-var">pinsts'</span></a></span></span><span>  </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Ordering)
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Ordering
forall a b. Ord a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Ordering
</span><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier hs-var">comparing</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707531"><span class="hs-identifier hs-var">pinsts</span></a></span><span>
</span><span id="line-181"></span><span>           </span><span id="local-6989586621679707518"><span class="annot"><span class="annottext">pinstsOk :: Bool
</span><a href="#local-6989586621679707518"><span class="hs-identifier hs-var hs-var">pinstsOk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; Bool)
-&gt; [[InstalledPackageInfo]] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#all"><span class="hs-identifier hs-var">all</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679707516"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707516"><span class="hs-identifier hs-var">g</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707516"><span class="hs-identifier hs-var">g</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span class="hs-special">)</span><span>
</span><span id="line-182"></span><span>                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; [InstalledPackageInfo] -&gt; [[InstalledPackageInfo]]
forall a. (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [[a]]
</span><a href="../../base/src/Data.OldList.html#groupBy"><span class="hs-identifier hs-var">groupBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707528"><span class="hs-identifier hs-var">pinsts'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-183"></span><span>     </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707540"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707540"><span class="hs-identifier hs-var">pinst</span></a></span></span><span>           </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. HasCallStack =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="#local-6989586621679707518"><span class="hs-identifier hs-var">pinstsOk</span></a></span><span> </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707528"><span class="hs-identifier hs-var">pinsts'</span></a></span><span>
</span><span id="line-184"></span><span>     </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707541"><span class="annot"><span class="annottext">pinstOk :: Bool
</span><a href="#local-6989586621679707541"><span class="hs-identifier hs-var hs-var">pinstOk</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span>    </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707540"><span class="hs-identifier hs-var">pinst</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; PackageName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707539"><span class="hs-identifier hs-var">pname</span></a></span><span>
</span><span id="line-185"></span><span>                  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707540"><span class="hs-identifier hs-var">pinst</span></a></span><span> </span><span class="annot"><span class="annottext">Version -&gt; Version -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">Version
</span><a href="#local-6989586621679707532"><span class="hs-identifier hs-var">pver</span></a></span><span>
</span><span id="line-186"></span><span>                  </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">&amp;&amp;</span></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span>  </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707540"><span class="hs-identifier hs-var">pinst</span></a></span><span> </span><span class="annot"><span class="annottext">LibraryName -&gt; LibraryName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707538"><span class="hs-identifier hs-var">plib</span></a></span><span>
</span><span id="line-187"></span><span>     </span><span class="hs-special">]</span><span>
</span><span id="line-188"></span><span>  </span><span class="hs-comment">-- If you see this invariant failing (ie the assert in mkPackageIndex below)</span><span>
</span><span id="line-189"></span><span>  </span><span class="hs-comment">-- then one thing to check is if it is happening in fromList. Check if the</span><span>
</span><span id="line-190"></span><span>  </span><span class="hs-comment">-- second list above (the sort [...] bit) is ending up with duplicates. This</span><span>
</span><span id="line-191"></span><span>  </span><span class="hs-comment">-- has been observed in practice once due to a messed up ghc-pkg db. How/why</span><span>
</span><span id="line-192"></span><span>  </span><span class="hs-comment">-- it became messed up was not discovered.</span><span>
</span><span id="line-193"></span><span>
</span><span id="line-194"></span><span>
</span><span id="line-195"></span><span class="hs-comment">--</span><span>
</span><span id="line-196"></span><span class="hs-comment">-- * Internal helpers</span><span>
</span><span id="line-197"></span><span class="hs-comment">--</span><span>
</span><span id="line-198"></span><span>
</span><span id="line-199"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-type">mkPackageIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Compat.Stack.html#WithCallStack"><span class="hs-identifier hs-type">WithCallStack</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span>
</span><span id="line-200"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html#LibraryName"><span class="hs-identifier hs-type">LibraryName</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-201"></span><span>                      </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.Version.html#Version"><span class="hs-identifier hs-type">Version</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-202"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-203"></span><span id="mkPackageIndex"><span class="annot"><span class="annottext">mkPackageIndex :: WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var hs-var">mkPackageIndex</span></a></span></span><span> </span><span id="local-6989586621679707497"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707497"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707496"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707496"><span class="hs-identifier hs-var">pnames</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Bool
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
forall a. HasCallStack =&gt; Bool -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Base.html#assert"><span class="hs-identifier hs-var hs-var">assert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">WithCallStack (PackageIndex InstalledPackageInfo -&gt; Bool)
PackageIndex InstalledPackageInfo -&gt; Bool
</span><a href="Distribution.Simple.PackageIndex.html#invariant"><span class="hs-identifier hs-var">invariant</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707495"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707495"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-204"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679707495"><span class="annot"><span class="annottext">index :: PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707495"><span class="hs-identifier hs-var hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
forall a.
Map UnitId a
-&gt; Map (PackageName, LibraryName) (Map Version [a])
-&gt; PackageIndex a
</span><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-var">PackageIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707497"><span class="hs-identifier hs-var">pids</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707496"><span class="hs-identifier hs-var">pnames</span></a></span><span>
</span><span id="line-205"></span><span>
</span><span id="line-206"></span><span>
</span><span id="line-207"></span><span class="hs-comment">--</span><span>
</span><span id="line-208"></span><span class="hs-comment">-- * Construction</span><span>
</span><span id="line-209"></span><span class="hs-comment">--</span><span>
</span><span id="line-210"></span><span>
</span><span id="line-211"></span><span class="hs-comment">-- | Build an index out of a bunch of packages.</span><span>
</span><span id="line-212"></span><span class="hs-comment">--</span><span>
</span><span id="line-213"></span><span class="hs-comment">-- If there are duplicates by 'UnitId' then later ones mask earlier</span><span>
</span><span id="line-214"></span><span class="hs-comment">-- ones.</span><span>
</span><span id="line-215"></span><span class="hs-comment">--</span><span>
</span><span id="line-216"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#fromList"><span class="hs-identifier hs-type">fromList</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-217"></span><span id="fromList"><span class="annot"><span class="annottext">fromList :: [InstalledPackageInfo] -&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#fromList"><span class="hs-identifier hs-var hs-var">fromList</span></a></span></span><span> </span><span id="local-6989586621679707494"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707494"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707493"><span class="hs-identifier hs-var">pids</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Map Version (NonEmpty InstalledPackageInfo)
 -&gt; Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName)
     (Map Version (NonEmpty InstalledPackageInfo))
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span> </span><span class="annot"><span class="annottext">((Map Version (NonEmpty InstalledPackageInfo)
  -&gt; Map Version [InstalledPackageInfo])
 -&gt; Map
      (PackageName, LibraryName)
      (Map Version (NonEmpty InstalledPackageInfo))
 -&gt; Map
      (PackageName, LibraryName) (Map Version [InstalledPackageInfo]))
-&gt; ((NonEmpty InstalledPackageInfo -&gt; [InstalledPackageInfo])
    -&gt; Map Version (NonEmpty InstalledPackageInfo)
    -&gt; Map Version [InstalledPackageInfo])
-&gt; (NonEmpty InstalledPackageInfo -&gt; [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName)
     (Map Version (NonEmpty InstalledPackageInfo))
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(NonEmpty InstalledPackageInfo -&gt; [InstalledPackageInfo])
-&gt; Map Version (NonEmpty InstalledPackageInfo)
-&gt; Map Version [InstalledPackageInfo]
forall (f :: * -&gt; *) a b. Functor f =&gt; (a -&gt; b) -&gt; f a -&gt; f b
</span><a href="../../base/src/GHC.Base.html#fmap"><span class="hs-identifier hs-var">fmap</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo -&gt; [InstalledPackageInfo]
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#toList"><span class="hs-identifier hs-var">toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map
  (PackageName, LibraryName)
  (Map Version (NonEmpty InstalledPackageInfo))
</span><a href="#local-6989586621679707490"><span class="hs-identifier hs-var">pnames</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-218"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-219"></span><span>    </span><span id="local-6989586621679707493"><span class="annot"><span class="annottext">pids :: Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707493"><span class="hs-identifier hs-var hs-var">pids</span></a></span></span><span>      </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(UnitId, InstalledPackageInfo)] -&gt; Map UnitId InstalledPackageInfo
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707486"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707486"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707486"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707486"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707494"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-220"></span><span>    </span><span id="local-6989586621679707490"><span class="annot"><span class="annottext">pnames :: Map
  (PackageName, LibraryName)
  (Map Version (NonEmpty InstalledPackageInfo))
</span><a href="#local-6989586621679707490"><span class="hs-identifier hs-var hs-var">pnames</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span>
</span><span id="line-221"></span><span>      </span><span class="annot"><span class="annottext">[((PackageName, LibraryName),
  Map Version (NonEmpty InstalledPackageInfo))]
-&gt; Map
     (PackageName, LibraryName)
     (Map Version (NonEmpty InstalledPackageInfo))
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span>
</span><span id="line-222"></span><span>        </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName -&gt; LibraryName -&gt; (PackageName, LibraryName))
-&gt; (InstalledPackageInfo -&gt; PackageName)
-&gt; (InstalledPackageInfo -&gt; LibraryName)
-&gt; InstalledPackageInfo
-&gt; (PackageName, LibraryName)
forall (m :: * -&gt; *) a1 a2 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM2"><span class="hs-identifier hs-var">liftM2</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo -&gt; InstalledPackageInfo
forall a. NonEmpty a -&gt; a
</span><a href="../../base/src/Data.List.NonEmpty.html#head"><span class="hs-identifier hs-var">NE.head</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707466"><span class="hs-identifier hs-var">pkgsN</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Map Version (NonEmpty InstalledPackageInfo)
</span><a href="#local-6989586621679707465"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-223"></span><span>        </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707466"><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707466"><span class="hs-identifier hs-var">pkgsN</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; [InstalledPackageInfo] -&gt; [NonEmpty InstalledPackageInfo]
forall (f :: * -&gt; *) a.
Foldable f =&gt;
(a -&gt; a -&gt; Bool) -&gt; f a -&gt; [NonEmpty a]
</span><a href="../../base/src/Data.List.NonEmpty.html#groupBy"><span class="hs-identifier hs-var">NE.groupBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; (PackageName, LibraryName))
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName -&gt; LibraryName -&gt; (PackageName, LibraryName))
-&gt; (InstalledPackageInfo -&gt; PackageName)
-&gt; (InstalledPackageInfo -&gt; LibraryName)
-&gt; InstalledPackageInfo
-&gt; (PackageName, LibraryName)
forall (m :: * -&gt; *) a1 a2 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM2"><span class="hs-identifier hs-var">liftM2</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-224"></span><span>                 </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; [NonEmpty InstalledPackageInfo])
-&gt; ([InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; [InstalledPackageInfo]
-&gt; [NonEmpty InstalledPackageInfo]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Ordering)
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span>  </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; (PackageName, LibraryName, Version))
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Ordering
forall a b. Ord a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Ordering
</span><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier hs-var">comparing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName
 -&gt; LibraryName -&gt; Version -&gt; (PackageName, LibraryName, Version))
-&gt; (InstalledPackageInfo -&gt; PackageName)
-&gt; (InstalledPackageInfo -&gt; LibraryName)
-&gt; (InstalledPackageInfo -&gt; Version)
-&gt; InstalledPackageInfo
-&gt; (PackageName, LibraryName, Version)
forall (m :: * -&gt; *) a1 a2 a3 r.
Monad m =&gt;
(a1 -&gt; a2 -&gt; a3 -&gt; r) -&gt; m a1 -&gt; m a2 -&gt; m a3 -&gt; m r
</span><a href="../../base/src/GHC.Base.html#liftM3"><span class="hs-identifier hs-var">liftM3</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">,</span><span class="hs-special">,</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-225"></span><span>                 </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; [NonEmpty InstalledPackageInfo])
-&gt; [InstalledPackageInfo] -&gt; [NonEmpty InstalledPackageInfo]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707494"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-226"></span><span>        </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707465"><span class="annot"><span class="annottext">pvers :: Map Version (NonEmpty InstalledPackageInfo)
</span><a href="#local-6989586621679707465"><span class="hs-identifier hs-var hs-var">pvers</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-227"></span><span>                </span><span class="annot"><span class="annottext">[(Version, NonEmpty InstalledPackageInfo)]
-&gt; Map Version (NonEmpty InstalledPackageInfo)
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span>
</span><span id="line-228"></span><span>                </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo -&gt; InstalledPackageInfo
forall a. NonEmpty a -&gt; a
</span><a href="../../base/src/Data.List.NonEmpty.html#head"><span class="hs-identifier hs-var">NE.head</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707455"><span class="hs-identifier hs-var">pkgsNV</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span>
</span><span id="line-229"></span><span>                   </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; NonEmpty InstalledPackageInfo -&gt; NonEmpty InstalledPackageInfo
forall a. (a -&gt; a -&gt; Bool) -&gt; NonEmpty a -&gt; NonEmpty a
</span><a href="../../base/src/Data.List.NonEmpty.html#nubBy"><span class="hs-identifier hs-var">NE.nubBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo -&gt; NonEmpty InstalledPackageInfo
forall a. NonEmpty a -&gt; NonEmpty a
</span><a href="../../base/src/Data.List.NonEmpty.html#reverse"><span class="hs-identifier hs-var">NE.reverse</span></a></span><span> </span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707455"><span class="hs-identifier hs-var">pkgsNV</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-230"></span><span>                </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707455"><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707455"><span class="hs-identifier hs-var">pkgsNV</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; NonEmpty InstalledPackageInfo -&gt; [NonEmpty InstalledPackageInfo]
forall (f :: * -&gt; *) a.
Foldable f =&gt;
(a -&gt; a -&gt; Bool) -&gt; f a -&gt; [NonEmpty a]
</span><a href="../../base/src/Data.List.NonEmpty.html#groupBy"><span class="hs-identifier hs-var">NE.groupBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; Version)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">NonEmpty InstalledPackageInfo
</span><a href="#local-6989586621679707466"><span class="hs-identifier hs-var">pkgsN</span></a></span><span>
</span><span id="line-231"></span><span>                </span><span class="hs-special">]</span><span>
</span><span id="line-232"></span><span>        </span><span class="hs-special">]</span><span>
</span><span id="line-233"></span><span>
</span><span id="line-234"></span><span class="hs-comment">--</span><span>
</span><span id="line-235"></span><span class="hs-comment">-- * Updates</span><span>
</span><span id="line-236"></span><span class="hs-comment">--</span><span>
</span><span id="line-237"></span><span>
</span><span id="line-238"></span><span class="hs-comment">-- | Merge two indexes.</span><span>
</span><span id="line-239"></span><span class="hs-comment">--</span><span>
</span><span id="line-240"></span><span class="hs-comment">-- Packages from the second mask packages from the first if they have the exact</span><span>
</span><span id="line-241"></span><span class="hs-comment">-- same 'UnitId'.</span><span>
</span><span id="line-242"></span><span class="hs-comment">--</span><span>
</span><span id="line-243"></span><span class="hs-comment">-- For packages with the same source 'PackageId', packages from the second are</span><span>
</span><span id="line-244"></span><span class="hs-comment">-- \&quot;preferred\&quot; over those from the first. Being preferred means they are top</span><span>
</span><span id="line-245"></span><span class="hs-comment">-- result when we do a lookup by source 'PackageId'. This is the mechanism we</span><span>
</span><span id="line-246"></span><span class="hs-comment">-- use to prefer user packages over global packages.</span><span>
</span><span id="line-247"></span><span class="hs-comment">--</span><span>
</span><span id="line-248"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#merge"><span class="hs-identifier hs-type">merge</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-249"></span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-250"></span><span id="merge"><span class="annot"><span class="annottext">merge :: PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#merge"><span class="hs-identifier hs-var hs-var">merge</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707452"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707452"><span class="hs-identifier hs-var">pids1</span></a></span></span><span> </span><span id="local-6989586621679707451"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707451"><span class="hs-identifier hs-var">pnames1</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707450"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707450"><span class="hs-identifier hs-var">pids2</span></a></span></span><span> </span><span id="local-6989586621679707449"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707449"><span class="hs-identifier hs-var">pnames2</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-251"></span><span>  </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo
 -&gt; InstalledPackageInfo -&gt; InstalledPackageInfo)
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; Map k a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#unionWith"><span class="hs-identifier hs-var">Map.unionWith</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679707447"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707447"><span class="hs-identifier hs-var">y</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707447"><span class="hs-identifier hs-var">y</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707452"><span class="hs-identifier hs-var">pids1</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707450"><span class="hs-identifier hs-var">pids2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-252"></span><span>                 </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Map Version [InstalledPackageInfo]
 -&gt; Map Version [InstalledPackageInfo]
 -&gt; Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; Map k a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#unionWith"><span class="hs-identifier hs-var">Map.unionWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([InstalledPackageInfo]
 -&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; Map k a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#unionWith"><span class="hs-identifier hs-var">Map.unionWith</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707446"><span class="hs-identifier hs-var">mergeBuckets</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707451"><span class="hs-identifier hs-var">pnames1</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707449"><span class="hs-identifier hs-var">pnames2</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-253"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-254"></span><span>    </span><span class="hs-comment">-- Packages in the second list mask those in the first, however preferred</span><span>
</span><span id="line-255"></span><span>    </span><span class="hs-comment">-- packages go first in the list.</span><span>
</span><span id="line-256"></span><span>    </span><span id="local-6989586621679707446"><span class="annot"><span class="annottext">mergeBuckets :: [InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707446"><span class="hs-identifier hs-var hs-var">mergeBuckets</span></a></span></span><span> </span><span id="local-6989586621679707445"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707445"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span id="local-6989586621679707444"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707444"><span class="hs-identifier hs-var">ys</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707444"><span class="hs-identifier hs-var">ys</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707445"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707443"><span class="hs-operator hs-var">\\</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707444"><span class="hs-identifier hs-var">ys</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-257"></span><span>    </span><span id="local-6989586621679707443"><span class="annot"><span class="annottext">\\ :: [InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707443"><span class="hs-operator hs-var hs-var">(\\)</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; [InstalledPackageInfo]
-&gt; [InstalledPackageInfo]
-&gt; [InstalledPackageInfo]
forall a. (a -&gt; a -&gt; Bool) -&gt; [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#deleteFirstsBy"><span class="hs-identifier hs-var">deleteFirstsBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-258"></span><span>
</span><span id="line-259"></span><span>
</span><span id="line-260"></span><span class="hs-comment">-- | Inserts a single package into the index.</span><span>
</span><span id="line-261"></span><span class="hs-comment">--</span><span>
</span><span id="line-262"></span><span class="hs-comment">-- This is equivalent to (but slightly quicker than) using 'mappend' or</span><span>
</span><span id="line-263"></span><span class="hs-comment">-- 'merge' with a singleton index.</span><span>
</span><span id="line-264"></span><span class="hs-comment">--</span><span>
</span><span id="line-265"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#insert"><span class="hs-identifier hs-type">insert</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-266"></span><span id="insert"><span class="annot"><span class="annottext">insert :: InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#insert"><span class="hs-identifier hs-var hs-var">insert</span></a></span></span><span> </span><span id="local-6989586621679707440"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707439"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707439"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707438"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707438"><span class="hs-identifier hs-var">pnames</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-267"></span><span>    </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707437"><span class="hs-identifier hs-var">pids'</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707436"><span class="hs-identifier hs-var">pnames'</span></a></span><span>
</span><span id="line-268"></span><span>
</span><span id="line-269"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-270"></span><span>    </span><span id="local-6989586621679707437"><span class="annot"><span class="annottext">pids' :: Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707437"><span class="hs-identifier hs-var hs-var">pids'</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnitId
-&gt; InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall k a. Ord k =&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#insert"><span class="hs-identifier hs-var">Map.insert</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707439"><span class="hs-identifier hs-var">pids</span></a></span><span>
</span><span id="line-271"></span><span>    </span><span id="local-6989586621679707436"><span class="annot"><span class="annottext">pnames' :: Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707436"><span class="hs-identifier hs-var hs-var">pnames'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707432"><span class="hs-identifier hs-var">insertPackageName</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707438"><span class="hs-identifier hs-var">pnames</span></a></span><span>
</span><span id="line-272"></span><span>    </span><span id="local-6989586621679707432"><span class="annot"><span class="annottext">insertPackageName :: Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707432"><span class="hs-identifier hs-var hs-var">insertPackageName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-273"></span><span>      </span><span class="annot"><span class="annottext">(Map Version [InstalledPackageInfo]
 -&gt; Map Version [InstalledPackageInfo]
 -&gt; Map Version [InstalledPackageInfo])
-&gt; (PackageName, LibraryName)
-&gt; Map Version [InstalledPackageInfo]
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#insertWith"><span class="hs-identifier hs-var">Map.insertWith</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707425"><span class="hs-identifier hs-var">insertPackageVersion</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-274"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-275"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Version
-&gt; [InstalledPackageInfo] -&gt; Map Version [InstalledPackageInfo]
forall k a. k -&gt; a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#singleton"><span class="hs-identifier hs-var">Map.singleton</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-276"></span><span>
</span><span id="line-277"></span><span>    </span><span id="local-6989586621679707425"><span class="annot"><span class="annottext">insertPackageVersion :: Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707425"><span class="hs-identifier hs-var hs-var">insertPackageVersion</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-278"></span><span>      </span><span class="annot"><span class="annottext">([InstalledPackageInfo]
 -&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; Version
-&gt; [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; k -&gt; a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#insertWith"><span class="hs-identifier hs-var">Map.insertWith</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707421"><span class="hs-identifier hs-var">insertPackageInstance</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-279"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-280"></span><span>
</span><span id="line-281"></span><span>    </span><span id="local-6989586621679707421"><span class="annot"><span class="annottext">insertPackageInstance :: [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
</span><a href="#local-6989586621679707421"><span class="hs-identifier hs-var hs-var">insertPackageInstance</span></a></span></span><span> </span><span id="local-6989586621679707418"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707418"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-282"></span><span>      </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; InstalledPackageInfo
-&gt; [InstalledPackageInfo]
-&gt; [InstalledPackageInfo]
forall a. (a -&gt; a -&gt; Bool) -&gt; a -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#deleteBy"><span class="hs-identifier hs-var">deleteBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool
forall a b. Eq a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Bool
</span><a href="Distribution.Utils.Generic.html#equating"><span class="hs-identifier hs-var">equating</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707440"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707418"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-283"></span><span>
</span><span id="line-284"></span><span>
</span><span id="line-285"></span><span class="hs-comment">-- | Removes a single installed package from the index.</span><span>
</span><span id="line-286"></span><span class="hs-comment">--</span><span>
</span><span id="line-287"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deleteUnitId"><span class="hs-identifier hs-type">deleteUnitId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-288"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-289"></span><span id="deleteUnitId"><span class="annot"><span class="annottext">deleteUnitId :: UnitId
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#deleteUnitId"><span class="hs-identifier hs-var hs-var">deleteUnitId</span></a></span></span><span> </span><span id="local-6989586621679707417"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707417"><span class="hs-identifier hs-var">ipkgid</span></a></span></span><span> </span><span id="local-6989586621679707416"><span class="annot"><span class="annottext">original :: PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707416"><span class="hs-identifier hs-var">original</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707415"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707415"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707414"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707414"><span class="hs-identifier hs-var">pnames</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-290"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(UnitId -&gt; InstalledPackageInfo -&gt; Maybe InstalledPackageInfo)
-&gt; UnitId
-&gt; Map UnitId InstalledPackageInfo
-&gt; (Maybe InstalledPackageInfo, Map UnitId InstalledPackageInfo)
forall k a.
Ord k =&gt;
(k -&gt; a -&gt; Maybe a) -&gt; k -&gt; Map k a -&gt; (Maybe a, Map k a)
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#updateLookupWithKey"><span class="hs-identifier hs-var">Map.updateLookupWithKey</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">UnitId
</span><span class="hs-identifier">_</span></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><span class="hs-identifier">_</span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe InstalledPackageInfo
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707417"><span class="hs-identifier hs-var">ipkgid</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707415"><span class="hs-identifier hs-var">pids</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-291"></span><span>    </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Maybe InstalledPackageInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span class="hs-special">,</span><span>     </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707416"><span class="hs-identifier hs-var">original</span></a></span><span>
</span><span id="line-292"></span><span>    </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707412"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707412"><span class="hs-identifier hs-var">spkgid</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707411"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707411"><span class="hs-identifier hs-var">pids'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707411"><span class="hs-identifier hs-var">pids'</span></a></span><span>
</span><span id="line-293"></span><span>                                          </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707410"><span class="hs-identifier hs-var">deletePkgName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707412"><span class="hs-identifier hs-var">spkgid</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707414"><span class="hs-identifier hs-var">pnames</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-294"></span><span>
</span><span id="line-295"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-296"></span><span>    </span><span id="local-6989586621679707410"><span class="annot"><span class="annottext">deletePkgName :: InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707410"><span class="hs-identifier hs-var hs-var">deletePkgName</span></a></span></span><span> </span><span id="local-6989586621679707404"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707404"><span class="hs-identifier hs-var">spkgid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-297"></span><span>      </span><span class="annot"><span class="annottext">(Map Version [InstalledPackageInfo]
 -&gt; Maybe (Map Version [InstalledPackageInfo]))
-&gt; (PackageName, LibraryName)
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; (a -&gt; Maybe a) -&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#update"><span class="hs-identifier hs-var">Map.update</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo
-&gt; Map Version [InstalledPackageInfo]
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall {pkg}.
Package pkg =&gt;
pkg
-&gt; Map Version [InstalledPackageInfo]
-&gt; Maybe (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707402"><span class="hs-identifier hs-var">deletePkgVersion</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707404"><span class="hs-identifier hs-var">spkgid</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707404"><span class="hs-identifier hs-var">spkgid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707404"><span class="hs-identifier hs-var">spkgid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-298"></span><span>
</span><span id="line-299"></span><span>    </span><span id="local-6989586621679707402"><span class="annot"><span class="annottext">deletePkgVersion :: pkg
-&gt; Map Version [InstalledPackageInfo]
-&gt; Maybe (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707402"><span class="hs-identifier hs-var hs-var">deletePkgVersion</span></a></span></span><span> </span><span id="local-6989586621679707398"><span class="annot"><span class="annottext">pkg
</span><a href="#local-6989586621679707398"><span class="hs-identifier hs-var">spkgid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-300"></span><span>        </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679707397"><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707397"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo] -&gt; Bool
forall k a. Map k a -&gt; Bool
</span><a href="../../containers/src/Data.Map.Internal.html#null"><span class="hs-identifier hs-var">Map.null</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707397"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe (Map Version [InstalledPackageInfo])
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707397"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-301"></span><span>      </span><span class="annot"><span class="annottext">(Map Version [InstalledPackageInfo]
 -&gt; Maybe (Map Version [InstalledPackageInfo]))
-&gt; (Map Version [InstalledPackageInfo]
    -&gt; Map Version [InstalledPackageInfo])
-&gt; Map Version [InstalledPackageInfo]
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; Maybe [InstalledPackageInfo])
-&gt; Version
-&gt; Map Version [InstalledPackageInfo]
-&gt; Map Version [InstalledPackageInfo]
forall k a. Ord k =&gt; (a -&gt; Maybe a) -&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#update"><span class="hs-identifier hs-var">Map.update</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; Maybe [InstalledPackageInfo]
</span><a href="#local-6989586621679707396"><span class="hs-identifier hs-var">deletePkgInstance</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">pkg -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">pkg
</span><a href="#local-6989586621679707398"><span class="hs-identifier hs-var">spkgid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-302"></span><span>
</span><span id="line-303"></span><span>    </span><span id="local-6989586621679707396"><span class="annot"><span class="annottext">deletePkgInstance :: [InstalledPackageInfo] -&gt; Maybe [InstalledPackageInfo]
</span><a href="#local-6989586621679707396"><span class="hs-identifier hs-var hs-var">deletePkgInstance</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-304"></span><span>        </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679707390"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707390"><span class="hs-identifier hs-var">xs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707390"><span class="hs-identifier hs-var">xs</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe [InstalledPackageInfo]
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; Maybe [InstalledPackageInfo]
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707390"><span class="hs-identifier hs-var">xs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-305"></span><span>      </span><span class="annot"><span class="annottext">([InstalledPackageInfo] -&gt; Maybe [InstalledPackageInfo])
-&gt; ([InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; [InstalledPackageInfo]
-&gt; Maybe [InstalledPackageInfo]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; InstalledPackageInfo -&gt; Bool)
-&gt; InstalledPackageInfo
-&gt; [InstalledPackageInfo]
-&gt; [InstalledPackageInfo]
forall a. (a -&gt; a -&gt; Bool) -&gt; a -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#deleteBy"><span class="hs-identifier hs-var">List.deleteBy</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679707388"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707388"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707388"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; UnitId -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707417"><span class="hs-identifier hs-var">ipkgid</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
forall a. HasCallStack =&gt; a
</span><a href="../../base/src/GHC.Err.html#undefined"><span class="hs-identifier hs-var">undefined</span></a></span><span>
</span><span id="line-306"></span><span>
</span><span id="line-307"></span><span class="hs-comment">-- | Removes all packages with this source 'PackageId' from the index.</span><span>
</span><span id="line-308"></span><span class="hs-comment">--</span><span>
</span><span id="line-309"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deleteSourcePackageId"><span class="hs-identifier hs-type">deleteSourcePackageId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.PackageId.html#PackageId"><span class="hs-identifier hs-type">PackageId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-310"></span><span>                      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-311"></span><span id="deleteSourcePackageId"><span class="annot"><span class="annottext">deleteSourcePackageId :: PackageId
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#deleteSourcePackageId"><span class="hs-identifier hs-var hs-var">deleteSourcePackageId</span></a></span></span><span> </span><span id="local-6989586621679707386"><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707386"><span class="hs-identifier hs-var">pkgid</span></a></span></span><span> </span><span id="local-6989586621679707385"><span class="annot"><span class="annottext">original :: PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707385"><span class="hs-identifier hs-var">original</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707384"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707384"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707383"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707383"><span class="hs-identifier hs-var">pnames</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-312"></span><span>  </span><span class="hs-comment">-- NB: Doesn't delete internal packages</span><span>
</span><span id="line-313"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707386"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707383"><span class="hs-identifier hs-var">pnames</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-314"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Map Version [InstalledPackageInfo])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707385"><span class="hs-identifier hs-var">original</span></a></span><span>
</span><span id="line-315"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707380"><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707380"><span class="hs-identifier hs-var">pvers</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Version
-&gt; Map Version [InstalledPackageInfo]
-&gt; Maybe [InstalledPackageInfo]
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707386"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707380"><span class="hs-identifier hs-var">pvers</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-316"></span><span>      </span><span class="annot"><span class="annottext">Maybe [InstalledPackageInfo]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707385"><span class="hs-identifier hs-var">original</span></a></span><span>
</span><span id="line-317"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707379"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707379"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span>
</span><span id="line-318"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Map UnitId InstalledPackageInfo
 -&gt; InstalledPackageInfo -&gt; Map UnitId InstalledPackageInfo)
-&gt; Map UnitId InstalledPackageInfo
-&gt; [InstalledPackageInfo]
-&gt; Map UnitId InstalledPackageInfo
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo)
-&gt; Map UnitId InstalledPackageInfo
-&gt; InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitId
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#delete"><span class="hs-identifier hs-var">Map.delete</span></a></span><span> </span><span class="annot"><span class="annottext">(UnitId
 -&gt; Map UnitId InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo)
-&gt; (InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707384"><span class="hs-identifier hs-var">pids</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707379"><span class="hs-identifier hs-var">pkgs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-319"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall {a}.
Map (PackageName, LibraryName) (Map Version a)
-&gt; Map (PackageName, LibraryName) (Map Version a)
</span><a href="#local-6989586621679707375"><span class="hs-identifier hs-var">deletePkgName</span></a></span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707383"><span class="hs-identifier hs-var">pnames</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-320"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-321"></span><span>    </span><span id="local-6989586621679707375"><span class="annot"><span class="annottext">deletePkgName :: Map (PackageName, LibraryName) (Map Version a)
-&gt; Map (PackageName, LibraryName) (Map Version a)
</span><a href="#local-6989586621679707375"><span class="hs-identifier hs-var hs-var">deletePkgName</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-322"></span><span>      </span><span class="annot"><span class="annottext">(Map Version a -&gt; Maybe (Map Version a))
-&gt; (PackageName, LibraryName)
-&gt; Map (PackageName, LibraryName) (Map Version a)
-&gt; Map (PackageName, LibraryName) (Map Version a)
forall k a. Ord k =&gt; (a -&gt; Maybe a) -&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#update"><span class="hs-identifier hs-var">Map.update</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version a -&gt; Maybe (Map Version a)
forall {a}. Map Version a -&gt; Maybe (Map Version a)
</span><a href="#local-6989586621679707370"><span class="hs-identifier hs-var">deletePkgVersion</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707386"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-323"></span><span>
</span><span id="line-324"></span><span>    </span><span id="local-6989586621679707370"><span class="annot"><span class="annottext">deletePkgVersion :: Map Version a -&gt; Maybe (Map Version a)
</span><a href="#local-6989586621679707370"><span class="hs-identifier hs-var hs-var">deletePkgVersion</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-325"></span><span>        </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679707367"><span class="annot"><span class="annottext">Map Version a
</span><a href="#local-6989586621679707367"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">if</span><span> </span><span class="annot"><span class="annottext">Map Version a -&gt; Bool
forall k a. Map k a -&gt; Bool
</span><a href="../../containers/src/Data.Map.Internal.html#null"><span class="hs-identifier hs-var">Map.null</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version a
</span><a href="#local-6989586621679707367"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="hs-keyword">then</span><span> </span><span class="annot"><span class="annottext">Maybe (Map Version a)
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-keyword">else</span><span> </span><span class="annot"><span class="annottext">Map Version a -&gt; Maybe (Map Version a)
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version a
</span><a href="#local-6989586621679707367"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-326"></span><span>      </span><span class="annot"><span class="annottext">(Map Version a -&gt; Maybe (Map Version a))
-&gt; (Map Version a -&gt; Map Version a)
-&gt; Map Version a
-&gt; Maybe (Map Version a)
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Version -&gt; Map Version a -&gt; Map Version a
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#delete"><span class="hs-identifier hs-var">Map.delete</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707386"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-327"></span><span>
</span><span id="line-328"></span><span>
</span><span id="line-329"></span><span class="hs-comment">-- | Removes all packages with this (case-sensitive) name from the index.</span><span>
</span><span id="line-330"></span><span class="hs-comment">--</span><span>
</span><span id="line-331"></span><span class="hs-comment">-- NB: Does NOT delete internal libraries from this package.</span><span>
</span><span id="line-332"></span><span class="hs-comment">--</span><span>
</span><span id="line-333"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#deletePackageName"><span class="hs-identifier hs-type">deletePackageName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-334"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-335"></span><span id="deletePackageName"><span class="annot"><span class="annottext">deletePackageName :: PackageName
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#deletePackageName"><span class="hs-identifier hs-var hs-var">deletePackageName</span></a></span></span><span> </span><span id="local-6989586621679707366"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707366"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621679707365"><span class="annot"><span class="annottext">original :: PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707365"><span class="hs-identifier hs-var">original</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span id="local-6989586621679707364"><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707364"><span class="hs-identifier hs-var">pids</span></a></span></span><span> </span><span id="local-6989586621679707363"><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707363"><span class="hs-identifier hs-var">pnames</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-336"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707366"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707363"><span class="hs-identifier hs-var">pnames</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-337"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Map Version [InstalledPackageInfo])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707365"><span class="hs-identifier hs-var">original</span></a></span><span>
</span><span id="line-338"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707362"><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707362"><span class="hs-identifier hs-var">pvers</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">WithCallStack
  (Map UnitId InstalledPackageInfo
   -&gt; Map
        (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
   -&gt; PackageIndex InstalledPackageInfo)
Map UnitId InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#mkPackageIndex"><span class="hs-identifier hs-var">mkPackageIndex</span></a></span><span>
</span><span id="line-339"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(Map UnitId InstalledPackageInfo
 -&gt; InstalledPackageInfo -&gt; Map UnitId InstalledPackageInfo)
-&gt; Map UnitId InstalledPackageInfo
-&gt; [InstalledPackageInfo]
-&gt; Map UnitId InstalledPackageInfo
forall (t :: * -&gt; *) b a.
Foldable t =&gt;
(b -&gt; a -&gt; b) -&gt; b -&gt; t a -&gt; b
</span><a href="../../base/src/Data.Foldable.html#foldl%27"><span class="hs-identifier hs-var">foldl'</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo)
-&gt; Map UnitId InstalledPackageInfo
-&gt; InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall a b c. (a -&gt; b -&gt; c) -&gt; b -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#flip"><span class="hs-identifier hs-var">flip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitId
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#delete"><span class="hs-identifier hs-var">Map.delete</span></a></span><span> </span><span class="annot"><span class="annottext">(UnitId
 -&gt; Map UnitId InstalledPackageInfo
 -&gt; Map UnitId InstalledPackageInfo)
-&gt; (InstalledPackageInfo -&gt; UnitId)
-&gt; InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
-&gt; Map UnitId InstalledPackageInfo
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map UnitId InstalledPackageInfo
</span><a href="#local-6989586621679707364"><span class="hs-identifier hs-var">pids</span></a></span><span>
</span><span id="line-340"></span><span>                             </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[InstalledPackageInfo]] -&gt; [InstalledPackageInfo]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo] -&gt; [[InstalledPackageInfo]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707362"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-341"></span><span>                     </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Internal.html#delete"><span class="hs-identifier hs-var">Map.delete</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707366"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
</span><a href="#local-6989586621679707363"><span class="hs-identifier hs-var">pnames</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-342"></span><span>
</span><span id="line-343"></span><span class="hs-comment">{-
-- | Removes all packages satisfying this dependency from the index.
--
deleteDependency :: Dependency -&gt; PackageIndex -&gt; PackageIndex
deleteDependency (Dependency name verstionRange) =
  delete' name (\pkg -&gt; packageVersion pkg `withinRange` verstionRange)
-}</span><span>
</span><span id="line-350"></span><span>
</span><span id="line-351"></span><span class="hs-comment">--</span><span>
</span><span id="line-352"></span><span class="hs-comment">-- * Bulk queries</span><span>
</span><span id="line-353"></span><span class="hs-comment">--</span><span>
</span><span id="line-354"></span><span>
</span><span id="line-355"></span><span class="hs-comment">-- | Get all the packages from the index.</span><span>
</span><span id="line-356"></span><span class="hs-comment">--</span><span>
</span><span id="line-357"></span><span id="local-6989586621679708010"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-type">allPackages</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708010"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679708010"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-358"></span><span id="allPackages"><span class="annot"><span class="annottext">allPackages :: forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var hs-var">allPackages</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map UnitId a -&gt; [a]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">(Map UnitId a -&gt; [a])
-&gt; (PackageIndex a -&gt; Map UnitId a) -&gt; PackageIndex a -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map UnitId a
forall a. PackageIndex a -&gt; Map UnitId a
</span><a href="Distribution.Simple.PackageIndex.html#unitIdIndex"><span class="hs-identifier hs-var hs-var">unitIdIndex</span></a></span><span>
</span><span id="line-359"></span><span>
</span><span id="line-360"></span><span class="hs-comment">-- | Get all the packages from the index.</span><span>
</span><span id="line-361"></span><span class="hs-comment">--</span><span>
</span><span id="line-362"></span><span class="hs-comment">-- They are grouped by package name (case-sensitively).</span><span>
</span><span id="line-363"></span><span class="hs-comment">--</span><span>
</span><span id="line-364"></span><span class="hs-comment">-- (Doesn't include private libraries.)</span><span>
</span><span id="line-365"></span><span class="hs-comment">--</span><span>
</span><span id="line-366"></span><span id="local-6989586621679708008"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesByName"><span class="hs-identifier hs-type">allPackagesByName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708008"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679708008"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-367"></span><span id="allPackagesByName"><span class="annot"><span class="annottext">allPackagesByName :: forall a. PackageIndex a -&gt; [(PackageName, [a])]
</span><a href="Distribution.Simple.PackageIndex.html#allPackagesByName"><span class="hs-identifier hs-var hs-var">allPackagesByName</span></a></span></span><span> </span><span id="local-6989586621679707359"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707359"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-368"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707358"><span class="hs-identifier hs-var">pkgname</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[[a]] -&gt; [a]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707357"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-369"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679707358"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707358"><span class="hs-identifier hs-var">pkgname</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707357"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707357"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [a])
-&gt; [((PackageName, LibraryName), Map Version [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707359"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-370"></span><span>
</span><span id="line-371"></span><span class="hs-comment">-- | Get all the packages from the index.</span><span>
</span><span id="line-372"></span><span class="hs-comment">--</span><span>
</span><span id="line-373"></span><span class="hs-comment">-- They are grouped by source package id (package name and version).</span><span>
</span><span id="line-374"></span><span class="hs-comment">--</span><span>
</span><span id="line-375"></span><span class="hs-comment">-- (Doesn't include private libraries)</span><span>
</span><span id="line-376"></span><span class="hs-comment">--</span><span>
</span><span id="line-377"></span><span id="local-6989586621679708006"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageId"><span class="hs-identifier hs-type">allPackagesBySourcePackageId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#HasUnitId"><span class="hs-identifier hs-type">HasUnitId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708006"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708006"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-378"></span><span>                             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageId.html#PackageId"><span class="hs-identifier hs-type">PackageId</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679708006"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-379"></span><span id="allPackagesBySourcePackageId"><span class="annot"><span class="annottext">allPackagesBySourcePackageId :: forall a. HasUnitId a =&gt; PackageIndex a -&gt; [(PackageId, [a])]
</span><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageId"><span class="hs-identifier hs-var hs-var">allPackagesBySourcePackageId</span></a></span></span><span> </span><span id="local-6989586621679707352"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707352"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-380"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; PackageId
forall pkg. Package pkg =&gt; pkg -&gt; PackageId
</span><a href="Distribution.Package.html#packageId"><span class="hs-identifier hs-var">packageId</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707350"><span class="hs-identifier hs-var">ipkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707349"><span class="hs-identifier hs-var">ipkgs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-381"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707348"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707348"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [a])
-&gt; [((PackageName, LibraryName), Map Version [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707352"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-382"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707349"><span class="annot"><span class="annottext">ipkgs :: [a]
</span><a href="#local-6989586621679707349"><span class="hs-identifier hs-var">ipkgs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621679707350"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707350"><span class="hs-identifier hs-var">ipkg</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707348"><span class="hs-identifier hs-var">pvers</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-383"></span><span>
</span><span id="line-384"></span><span class="hs-comment">-- | Get all the packages from the index.</span><span>
</span><span id="line-385"></span><span class="hs-comment">--</span><span>
</span><span id="line-386"></span><span class="hs-comment">-- They are grouped by source package id and library name.</span><span>
</span><span id="line-387"></span><span class="hs-comment">--</span><span>
</span><span id="line-388"></span><span class="hs-comment">-- This DOES include internal libraries.</span><span>
</span><span id="line-389"></span><span id="local-6989586621679708003"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageIdAndLibName"><span class="hs-identifier hs-type">allPackagesBySourcePackageIdAndLibName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#HasUnitId"><span class="hs-identifier hs-type">HasUnitId</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708003"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708003"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-390"></span><span>                             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageId.html#PackageId"><span class="hs-identifier hs-type">PackageId</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html#LibraryName"><span class="hs-identifier hs-type">LibraryName</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679708003"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-391"></span><span id="allPackagesBySourcePackageIdAndLibName"><span class="annot"><span class="annottext">allPackagesBySourcePackageIdAndLibName :: forall a.
HasUnitId a =&gt;
PackageIndex a -&gt; [((PackageId, LibraryName), [a])]
</span><a href="Distribution.Simple.PackageIndex.html#allPackagesBySourcePackageIdAndLibName"><span class="hs-identifier hs-var hs-var">allPackagesBySourcePackageIdAndLibName</span></a></span></span><span> </span><span id="local-6989586621679707344"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707344"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-392"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; PackageId
forall pkg. Package pkg =&gt; pkg -&gt; PackageId
</span><a href="Distribution.Package.html#packageId"><span class="hs-identifier hs-var">packageId</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707343"><span class="hs-identifier hs-var">ipkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707342"><span class="hs-identifier hs-var">ln</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707341"><span class="hs-identifier hs-var">ipkgs</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-393"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707342"><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707342"><span class="hs-identifier hs-var">ln</span></a></span></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707340"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707340"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [a])
-&gt; [((PackageName, LibraryName), Map Version [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707344"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-394"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707341"><span class="annot"><span class="annottext">ipkgs :: [a]
</span><a href="#local-6989586621679707341"><span class="hs-identifier hs-var">ipkgs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span id="local-6989586621679707343"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707343"><span class="hs-identifier hs-var">ipkg</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707340"><span class="hs-identifier hs-var">pvers</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-395"></span><span>
</span><span id="line-396"></span><span class="hs-comment">--</span><span>
</span><span id="line-397"></span><span class="hs-comment">-- * Lookups</span><span>
</span><span id="line-398"></span><span class="hs-comment">--</span><span>
</span><span id="line-399"></span><span>
</span><span id="line-400"></span><span class="hs-comment">-- | Does a lookup by unit identifier.</span><span>
</span><span id="line-401"></span><span class="hs-comment">--</span><span>
</span><span id="line-402"></span><span class="hs-comment">-- Since multiple package DBs mask each other by 'UnitId',</span><span>
</span><span id="line-403"></span><span class="hs-comment">-- then we get back at most one package.</span><span>
</span><span id="line-404"></span><span class="hs-comment">--</span><span>
</span><span id="line-405"></span><span id="local-6989586621679708001"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-type">lookupUnitId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708001"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span>
</span><span id="line-406"></span><span>             </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679708001"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-407"></span><span id="lookupUnitId"><span class="annot"><span class="annottext">lookupUnitId :: forall a. PackageIndex a -&gt; UnitId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-var hs-var">lookupUnitId</span></a></span></span><span> </span><span id="local-6989586621679707338"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707338"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707337"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707337"><span class="hs-identifier hs-var">uid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Map UnitId a -&gt; Maybe a
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707337"><span class="hs-identifier hs-var">uid</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map UnitId a
forall a. PackageIndex a -&gt; Map UnitId a
</span><a href="Distribution.Simple.PackageIndex.html#unitIdIndex"><span class="hs-identifier hs-var hs-var">unitIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707338"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-408"></span><span>
</span><span id="line-409"></span><span class="hs-comment">-- | Does a lookup by component identifier.  In the absence</span><span>
</span><span id="line-410"></span><span class="hs-comment">-- of Backpack, this is just a 'lookupUnitId'.</span><span>
</span><span id="line-411"></span><span class="hs-comment">--</span><span>
</span><span id="line-412"></span><span id="local-6989586621679707999"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupComponentId"><span class="hs-identifier hs-type">lookupComponentId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707999"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.ComponentId.html#ComponentId"><span class="hs-identifier hs-type">ComponentId</span></a></span><span>
</span><span id="line-413"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707999"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-414"></span><span id="lookupComponentId"><span class="annot"><span class="annottext">lookupComponentId :: forall a. PackageIndex a -&gt; ComponentId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupComponentId"><span class="hs-identifier hs-var hs-var">lookupComponentId</span></a></span></span><span> </span><span id="local-6989586621679707335"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707335"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707334"><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679707334"><span class="hs-identifier hs-var">cid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-415"></span><span>    </span><span class="annot"><span class="annottext">UnitId -&gt; Map UnitId a -&gt; Maybe a
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ComponentId -&gt; UnitId
</span><a href="Distribution.Types.UnitId.html#newSimpleUnitId"><span class="hs-identifier hs-var">newSimpleUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">ComponentId
</span><a href="#local-6989586621679707334"><span class="hs-identifier hs-var">cid</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map UnitId a
forall a. PackageIndex a -&gt; Map UnitId a
</span><a href="Distribution.Simple.PackageIndex.html#unitIdIndex"><span class="hs-identifier hs-var hs-var">unitIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707335"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-416"></span><span>
</span><span id="line-417"></span><span class="hs-comment">-- | Does a lookup by source package id (name &amp; version).</span><span>
</span><span id="line-418"></span><span class="hs-comment">--</span><span>
</span><span id="line-419"></span><span class="hs-comment">-- There can be multiple installed packages with the same source 'PackageId'</span><span>
</span><span id="line-420"></span><span class="hs-comment">-- but different 'UnitId'. They are returned in order of</span><span>
</span><span id="line-421"></span><span class="hs-comment">-- preference, with the most preferred first.</span><span>
</span><span id="line-422"></span><span class="hs-comment">--</span><span>
</span><span id="line-423"></span><span id="local-6989586621679707996"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupSourcePackageId"><span class="hs-identifier hs-type">lookupSourcePackageId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707996"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.PackageId.html#PackageId"><span class="hs-identifier hs-type">PackageId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707996"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-424"></span><span id="lookupSourcePackageId"><span class="annot"><span class="annottext">lookupSourcePackageId :: forall a. PackageIndex a -&gt; PackageId -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#lookupSourcePackageId"><span class="hs-identifier hs-var hs-var">lookupSourcePackageId</span></a></span></span><span> </span><span id="local-6989586621679707328"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707328"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707327"><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707327"><span class="hs-identifier hs-var">pkgid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-425"></span><span>  </span><span class="hs-comment">-- Do not lookup internal libraries</span><span>
</span><span id="line-426"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map (PackageName, LibraryName) (Map Version [a])
-&gt; Maybe (Map Version [a])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707327"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707328"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-427"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Map Version [a])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-428"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707326"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707326"><span class="hs-identifier hs-var">pvers</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Version -&gt; Map Version [a] -&gt; Maybe [a]
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageId -&gt; Version
forall pkg. Package pkg =&gt; pkg -&gt; Version
</span><a href="Distribution.Package.html#packageVersion"><span class="hs-identifier hs-var">packageVersion</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707327"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707326"><span class="hs-identifier hs-var">pvers</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-429"></span><span>      </span><span class="annot"><span class="annottext">Maybe [a]
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-430"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707325"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707325"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707325"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="hs-comment">-- in preference order</span><span>
</span><span id="line-431"></span><span>
</span><span id="line-432"></span><span class="hs-comment">-- | Convenient alias of 'lookupSourcePackageId', but assuming only</span><span>
</span><span id="line-433"></span><span class="hs-comment">-- one package per package ID.</span><span>
</span><span id="line-434"></span><span id="local-6989586621679707994"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupPackageId"><span class="hs-identifier hs-type">lookupPackageId</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707994"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.PackageId.html#PackageId"><span class="hs-identifier hs-type">PackageId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707994"><span class="hs-identifier hs-type">a</span></a></span></span><span>
</span><span id="line-435"></span><span id="lookupPackageId"><span class="annot"><span class="annottext">lookupPackageId :: forall a. PackageIndex a -&gt; PackageId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupPackageId"><span class="hs-identifier hs-var hs-var">lookupPackageId</span></a></span></span><span> </span><span id="local-6989586621679707322"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707322"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707321"><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707321"><span class="hs-identifier hs-var">pkgid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; PackageId -&gt; [a]
forall a. PackageIndex a -&gt; PackageId -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#lookupSourcePackageId"><span class="hs-identifier hs-var">lookupSourcePackageId</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707322"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="annot"><span class="annottext">PackageId
</span><a href="#local-6989586621679707321"><span class="hs-identifier hs-var">pkgid</span></a></span><span>  </span><span class="hs-keyword">of</span><span>
</span><span id="line-436"></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Maybe a
forall a. Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>
</span><span id="line-437"></span><span>    </span><span class="hs-special">[</span><span id="local-6989586621679707320"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707320"><span class="hs-identifier hs-var">pkg</span></a></span></span><span class="hs-special">]</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">a -&gt; Maybe a
forall a. a -&gt; Maybe a
</span><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-var">Just</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707320"><span class="hs-identifier hs-var">pkg</span></a></span><span>
</span><span id="line-438"></span><span>    </span><span class="annot"><span class="annottext">[a]
</span><span class="hs-identifier">_</span></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String -&gt; Maybe a
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;Distribution.Simple.PackageIndex: multiple matches found&quot;</span></span><span>
</span><span id="line-439"></span><span>
</span><span id="line-440"></span><span class="hs-comment">-- | Does a lookup by source package name.</span><span>
</span><span id="line-441"></span><span class="hs-comment">--</span><span>
</span><span id="line-442"></span><span id="local-6989586621679707990"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupPackageName"><span class="hs-identifier hs-type">lookupPackageName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707990"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span>
</span><span id="line-443"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.Version.html#Version"><span class="hs-identifier hs-type">Version</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707990"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-444"></span><span id="lookupPackageName"><span class="annot"><span class="annottext">lookupPackageName :: forall a. PackageIndex a -&gt; PackageName -&gt; [(Version, [a])]
</span><a href="Distribution.Simple.PackageIndex.html#lookupPackageName"><span class="hs-identifier hs-var hs-var">lookupPackageName</span></a></span></span><span> </span><span id="local-6989586621679707317"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707317"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707316"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707316"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-445"></span><span>  </span><span class="hs-comment">-- Do not match internal libraries</span><span>
</span><span id="line-446"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map (PackageName, LibraryName) (Map Version [a])
-&gt; Maybe (Map Version [a])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707316"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707317"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-447"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Map Version [a])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>     </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-448"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707315"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707315"><span class="hs-identifier hs-var">pvers</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">Map Version [a] -&gt; [(Version, [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707315"><span class="hs-identifier hs-var">pvers</span></a></span><span>
</span><span id="line-449"></span><span>
</span><span id="line-450"></span><span>
</span><span id="line-451"></span><span class="hs-comment">-- | Does a lookup by source package name and a range of versions.</span><span>
</span><span id="line-452"></span><span class="hs-comment">--</span><span>
</span><span id="line-453"></span><span class="hs-comment">-- We get back any number of versions of the specified package name, all</span><span>
</span><span id="line-454"></span><span class="hs-comment">-- satisfying the version range constraint.</span><span>
</span><span id="line-455"></span><span class="hs-comment">--</span><span>
</span><span id="line-456"></span><span class="hs-comment">-- This does NOT work for internal dependencies, DO NOT use this</span><span>
</span><span id="line-457"></span><span class="hs-comment">-- function on those; use 'lookupInternalDependency' instead.</span><span>
</span><span id="line-458"></span><span class="hs-comment">--</span><span>
</span><span id="line-459"></span><span class="hs-comment">-- INVARIANT: List of eligible 'IPI.InstalledPackageInfo' is non-empty.</span><span>
</span><span id="line-460"></span><span class="hs-comment">--</span><span>
</span><span id="line-461"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupDependency"><span class="hs-identifier hs-type">lookupDependency</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.VersionRange.Internal.html#VersionRange"><span class="hs-identifier hs-type">VersionRange</span></a></span><span>
</span><span id="line-462"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.Version.html#Version"><span class="hs-identifier hs-type">Version</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-463"></span><span id="lookupDependency"><span class="annot"><span class="annottext">lookupDependency :: PackageIndex InstalledPackageInfo
-&gt; PackageName
-&gt; VersionRange
-&gt; [(Version, [InstalledPackageInfo])]
</span><a href="Distribution.Simple.PackageIndex.html#lookupDependency"><span class="hs-identifier hs-var hs-var">lookupDependency</span></a></span></span><span> </span><span id="local-6989586621679707314"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707314"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707313"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707313"><span class="hs-identifier hs-var">pn</span></a></span></span><span> </span><span id="local-6989586621679707312"><span class="annot"><span class="annottext">VersionRange
</span><a href="#local-6989586621679707312"><span class="hs-identifier hs-var">vr</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-464"></span><span>    </span><span class="hs-comment">-- Yes, a little bit of a misnomer here!</span><span>
</span><span id="line-465"></span><span>    </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; PackageName
-&gt; VersionRange
-&gt; LibraryName
-&gt; [(Version, [InstalledPackageInfo])]
</span><a href="Distribution.Simple.PackageIndex.html#lookupInternalDependency"><span class="hs-identifier hs-var">lookupInternalDependency</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707314"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707313"><span class="hs-identifier hs-var">pn</span></a></span><span> </span><span class="annot"><span class="annottext">VersionRange
</span><a href="#local-6989586621679707312"><span class="hs-identifier hs-var">vr</span></a></span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span>
</span><span id="line-466"></span><span>
</span><span id="line-467"></span><span class="hs-comment">-- | Does a lookup by source package name and a range of versions.</span><span>
</span><span id="line-468"></span><span class="hs-comment">--</span><span>
</span><span id="line-469"></span><span class="hs-comment">-- We get back any number of versions of the specified package name, all</span><span>
</span><span id="line-470"></span><span class="hs-comment">-- satisfying the version range constraint.</span><span>
</span><span id="line-471"></span><span class="hs-comment">--</span><span>
</span><span id="line-472"></span><span class="hs-comment">-- INVARIANT: List of eligible 'IPI.InstalledPackageInfo' is non-empty.</span><span>
</span><span id="line-473"></span><span class="hs-comment">--</span><span>
</span><span id="line-474"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#lookupInternalDependency"><span class="hs-identifier hs-type">lookupInternalDependency</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.VersionRange.Internal.html#VersionRange"><span class="hs-identifier hs-type">VersionRange</span></a></span><span>
</span><span id="line-475"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html#LibraryName"><span class="hs-identifier hs-type">LibraryName</span></a></span><span>
</span><span id="line-476"></span><span>                 </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.Version.html#Version"><span class="hs-identifier hs-type">Version</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-477"></span><span id="lookupInternalDependency"><span class="annot"><span class="annottext">lookupInternalDependency :: PackageIndex InstalledPackageInfo
-&gt; PackageName
-&gt; VersionRange
-&gt; LibraryName
-&gt; [(Version, [InstalledPackageInfo])]
</span><a href="Distribution.Simple.PackageIndex.html#lookupInternalDependency"><span class="hs-identifier hs-var hs-var">lookupInternalDependency</span></a></span></span><span> </span><span id="local-6989586621679707311"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707311"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707310"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707310"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span id="local-6989586621679707309"><span class="annot"><span class="annottext">VersionRange
</span><a href="#local-6989586621679707309"><span class="hs-identifier hs-var">versionRange</span></a></span></span><span> </span><span id="local-6989586621679707308"><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707308"><span class="hs-identifier hs-var">libn</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-478"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName)
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
-&gt; Maybe (Map Version [InstalledPackageInfo])
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707310"><span class="hs-identifier hs-var">name</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="#local-6989586621679707308"><span class="hs-identifier hs-var">libn</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; Map
     (PackageName, LibraryName) (Map Version [InstalledPackageInfo])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707311"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-479"></span><span>    </span><span class="annot"><span class="annottext">Maybe (Map Version [InstalledPackageInfo])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>    </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-480"></span><span>    </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707307"><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707307"><span class="hs-identifier hs-var">pvers</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Version
</span><a href="#local-6989586621679707306"><span class="hs-identifier hs-var">ver</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707305"><span class="hs-identifier hs-var">pkgs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-481"></span><span>                  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707306"><span class="annot"><span class="annottext">Version
</span><a href="#local-6989586621679707306"><span class="hs-identifier hs-var">ver</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707304"><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707304"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
-&gt; [(Version, [InstalledPackageInfo])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [InstalledPackageInfo]
</span><a href="#local-6989586621679707307"><span class="hs-identifier hs-var">pvers</span></a></span><span>
</span><span id="line-482"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Version
</span><a href="#local-6989586621679707306"><span class="hs-identifier hs-var">ver</span></a></span><span> </span><span class="annot"><span class="annottext">Version -&gt; VersionRange -&gt; Bool
</span><a href="Distribution.Types.VersionRange.html#withinRange"><span class="hs-operator hs-var">`withinRange`</span></a></span><span> </span><span class="annot"><span class="annottext">VersionRange
</span><a href="#local-6989586621679707309"><span class="hs-identifier hs-var">versionRange</span></a></span><span>
</span><span id="line-483"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707305"><span class="annot"><span class="annottext">pkgs' :: [InstalledPackageInfo]
</span><a href="#local-6989586621679707305"><span class="hs-identifier hs-var hs-var">pkgs'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(InstalledPackageInfo -&gt; Bool)
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. (a -&gt; Bool) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.List.html#filter"><span class="hs-identifier hs-var">filter</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Bool
</span><a href="#local-6989586621679707302"><span class="hs-identifier hs-var">eligible</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707304"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-484"></span><span>                  </span><span class="hs-comment">-- Enforce the invariant</span><span>
</span><span id="line-485"></span><span>                  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[InstalledPackageInfo] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
</span><a href="#local-6989586621679707305"><span class="hs-identifier hs-var">pkgs'</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-486"></span><span>                  </span><span class="hs-special">]</span><span>
</span><span id="line-487"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-488"></span><span>  </span><span class="hs-comment">-- When we select for dependencies, we ONLY want to pick up indefinite</span><span>
</span><span id="line-489"></span><span>  </span><span class="hs-comment">-- packages, or packages with no instantiations.  We'll do mix-in</span><span>
</span><span id="line-490"></span><span>  </span><span class="hs-comment">-- linking to improve any such package into an instantiated one</span><span>
</span><span id="line-491"></span><span>  </span><span class="hs-comment">-- later.</span><span>
</span><span id="line-492"></span><span>  </span><span id="local-6989586621679707302"><span class="annot"><span class="annottext">eligible :: InstalledPackageInfo -&gt; Bool
</span><a href="#local-6989586621679707302"><span class="hs-identifier hs-var hs-var">eligible</span></a></span></span><span> </span><span id="local-6989586621679707300"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707300"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; Bool
</span><a href="Distribution.Types.InstalledPackageInfo.html#indefinite"><span class="hs-identifier hs-var hs-var">IPI.indefinite</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707300"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool -&gt; Bool
</span><span class="hs-operator hs-var">||</span></span><span> </span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; [(ModuleName, OpenModule)]
</span><a href="Distribution.Types.InstalledPackageInfo.html#instantiatedWith"><span class="hs-identifier hs-var hs-var">IPI.instantiatedWith</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707300"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-493"></span><span>
</span><span id="line-494"></span><span>
</span><span id="line-495"></span><span class="hs-comment">--</span><span>
</span><span id="line-496"></span><span class="hs-comment">-- * Case insensitive name lookups</span><span>
</span><span id="line-497"></span><span class="hs-comment">--</span><span>
</span><span id="line-498"></span><span>
</span><span id="line-499"></span><span class="hs-comment">-- | Does a case-insensitive search by package name.</span><span>
</span><span id="line-500"></span><span class="hs-comment">--</span><span>
</span><span id="line-501"></span><span class="hs-comment">-- If there is only one package that compares case-insensitively to this name</span><span>
</span><span id="line-502"></span><span class="hs-comment">-- then the search is unambiguous and we get back all versions of that package.</span><span>
</span><span id="line-503"></span><span class="hs-comment">-- If several match case-insensitively but one matches exactly then it is also</span><span>
</span><span id="line-504"></span><span class="hs-comment">-- unambiguous.</span><span>
</span><span id="line-505"></span><span class="hs-comment">--</span><span>
</span><span id="line-506"></span><span class="hs-comment">-- If however several match case-insensitively and none match exactly then we</span><span>
</span><span id="line-507"></span><span class="hs-comment">-- have an ambiguous result, and we get back all the versions of all the</span><span>
</span><span id="line-508"></span><span class="hs-comment">-- packages. The list of ambiguous results is split by exact package name. So</span><span>
</span><span id="line-509"></span><span class="hs-comment">-- it is a non-empty list of non-empty lists.</span><span>
</span><span id="line-510"></span><span class="hs-comment">--</span><span>
</span><span id="line-511"></span><span id="local-6989586621679707986"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchByName"><span class="hs-identifier hs-type">searchByName</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707986"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#SearchResult"><span class="hs-identifier hs-type">SearchResult</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707986"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-512"></span><span id="searchByName"><span class="annot"><span class="annottext">searchByName :: forall a. PackageIndex a -&gt; String -&gt; SearchResult [a]
</span><a href="Distribution.Simple.PackageIndex.html#searchByName"><span class="hs-identifier hs-var hs-var">searchByName</span></a></span></span><span> </span><span id="local-6989586621679707288"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707288"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707287"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707287"><span class="hs-identifier hs-var">name</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-513"></span><span>  </span><span class="hs-comment">-- Don't match internal packages</span><span>
</span><span id="line-514"></span><span>  </span><span class="hs-keyword">case</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">((PackageName, LibraryName), Map Version [a])
</span><a href="#local-6989586621679707286"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707286"><span class="annot"><span class="annottext">pkgs :: ((PackageName, LibraryName), Map Version [a])
</span><a href="#local-6989586621679707286"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span class="hs-glyph">@</span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679707285"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707285"><span class="hs-identifier hs-var">pname</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span class="annot"><span class="annottext">Map Version [a]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [a])
-&gt; [((PackageName, LibraryName), Map Version [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707288"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-515"></span><span>              </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">ShowS
</span><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-var">lowercase</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName -&gt; String
</span><a href="Distribution.Types.PackageName.html#unPackageName"><span class="hs-identifier hs-var">unPackageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707285"><span class="hs-identifier hs-var">pname</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707282"><span class="hs-identifier hs-var">lname</span></a></span><span> </span><span class="hs-special">]</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-516"></span><span>    </span><span class="hs-special">[</span><span class="hs-special">]</span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">SearchResult [a]
forall a. SearchResult a
</span><a href="Distribution.Simple.PackageIndex.html#None"><span class="hs-identifier hs-var">None</span></a></span><span>
</span><span id="line-517"></span><span>    </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName, LibraryName)
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679707280"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707280"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span class="hs-special">]</span><span>      </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; SearchResult [a]
forall a. a -&gt; SearchResult a
</span><a href="Distribution.Simple.PackageIndex.html#Unambiguous"><span class="hs-identifier hs-var">Unambiguous</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[a]] -&gt; [a]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707280"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-518"></span><span>    </span><span id="local-6989586621679707278"><span class="annot"><span class="annottext">[((PackageName, LibraryName), Map Version [a])]
</span><a href="#local-6989586621679707278"><span class="hs-identifier hs-var">pkgss</span></a></span></span><span>            </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">(((PackageName, LibraryName), Map Version [a]) -&gt; Bool)
-&gt; [((PackageName, LibraryName), Map Version [a])]
-&gt; Maybe ((PackageName, LibraryName), Map Version [a])
forall (t :: * -&gt; *) a. Foldable t =&gt; (a -&gt; Bool) -&gt; t a -&gt; Maybe a
</span><a href="../../base/src/Data.Foldable.html#find"><span class="hs-identifier hs-var">find</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span class="annot"><span class="annottext">String -&gt; PackageName
</span><a href="Distribution.Types.PackageName.html#mkPackageName"><span class="hs-identifier hs-var">mkPackageName</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707287"><span class="hs-identifier hs-var">name</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName -&gt; PackageName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">(PackageName -&gt; Bool)
-&gt; (((PackageName, LibraryName), Map Version [a]) -&gt; PackageName)
-&gt; ((PackageName, LibraryName), Map Version [a])
-&gt; Bool
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(PackageName, LibraryName) -&gt; PackageName
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span> </span><span class="annot"><span class="annottext">((PackageName, LibraryName) -&gt; PackageName)
-&gt; (((PackageName, LibraryName), Map Version [a])
    -&gt; (PackageName, LibraryName))
-&gt; ((PackageName, LibraryName), Map Version [a])
-&gt; PackageName
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((PackageName, LibraryName), Map Version [a])
-&gt; (PackageName, LibraryName)
forall a b. (a, b) -&gt; a
</span><a href="../../base/src/Data.Tuple.html#fst"><span class="hs-identifier hs-var">fst</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[((PackageName, LibraryName), Map Version [a])]
</span><a href="#local-6989586621679707278"><span class="hs-identifier hs-var">pkgss</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-519"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName, LibraryName)
</span><span class="hs-identifier">_</span></span><span class="hs-special">,</span><span id="local-6989586621679707275"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707275"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; SearchResult [a]
forall a. a -&gt; SearchResult a
</span><a href="Distribution.Simple.PackageIndex.html#Unambiguous"><span class="hs-identifier hs-var">Unambiguous</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[a]] -&gt; [a]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707275"><span class="hs-identifier hs-var">pvers</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-520"></span><span>      </span><span class="annot"><span class="annottext">Maybe ((PackageName, LibraryName), Map Version [a])
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>        </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[[a]] -&gt; SearchResult [a]
forall a. [a] -&gt; SearchResult a
</span><a href="Distribution.Simple.PackageIndex.html#Ambiguous"><span class="hs-identifier hs-var">Ambiguous</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(((PackageName, LibraryName), Map Version [a]) -&gt; [a])
-&gt; [((PackageName, LibraryName), Map Version [a])] -&gt; [[a]]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[[a]] -&gt; [a]
forall (t :: * -&gt; *) a. Foldable t =&gt; t [a] -&gt; [a]
</span><a href="../../base/src/Data.Foldable.html#concat"><span class="hs-identifier hs-var">concat</span></a></span><span> </span><span class="annot"><span class="annottext">([[a]] -&gt; [a])
-&gt; (((PackageName, LibraryName), Map Version [a]) -&gt; [[a]])
-&gt; ((PackageName, LibraryName), Map Version [a])
-&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">(Map Version [a] -&gt; [[a]])
-&gt; (((PackageName, LibraryName), Map Version [a])
    -&gt; Map Version [a])
-&gt; ((PackageName, LibraryName), Map Version [a])
-&gt; [[a]]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">((PackageName, LibraryName), Map Version [a]) -&gt; Map Version [a]
forall a b. (a, b) -&gt; b
</span><a href="../../base/src/Data.Tuple.html#snd"><span class="hs-identifier hs-var">snd</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[((PackageName, LibraryName), Map Version [a])]
</span><a href="#local-6989586621679707278"><span class="hs-identifier hs-var">pkgss</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-521"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679707282"><span class="annot"><span class="annottext">lname :: String
</span><a href="#local-6989586621679707282"><span class="hs-identifier hs-var hs-var">lname</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShowS
</span><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-var">lowercase</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707287"><span class="hs-identifier hs-var">name</span></a></span><span>
</span><span id="line-522"></span><span>
</span><span id="line-523"></span><span class="hs-keyword">data</span><span> </span><span id="SearchResult"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#SearchResult"><span class="hs-identifier hs-var">SearchResult</span></a></span></span><span> </span><span id="local-6989586621679707983"><span class="annot"><a href="#local-6989586621679707983"><span class="hs-identifier hs-type">a</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span id="None"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#None"><span class="hs-identifier hs-var">None</span></a></span></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="Unambiguous"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#Unambiguous"><span class="hs-identifier hs-var">Unambiguous</span></a></span></span><span> </span><span class="annot"><a href="#local-6989586621679707983"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="Ambiguous"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#Ambiguous"><span class="hs-identifier hs-var">Ambiguous</span></a></span></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707983"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-524"></span><span>
</span><span id="line-525"></span><span class="hs-comment">-- | Does a case-insensitive substring search by package name.</span><span>
</span><span id="line-526"></span><span class="hs-comment">--</span><span>
</span><span id="line-527"></span><span class="hs-comment">-- That is, all packages that contain the given string in their name.</span><span>
</span><span id="line-528"></span><span class="hs-comment">--</span><span>
</span><span id="line-529"></span><span id="local-6989586621679707976"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchByNameSubstring"><span class="hs-identifier hs-type">searchByNameSubstring</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707976"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707976"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-530"></span><span id="searchByNameSubstring"><span class="annot"><span class="annottext">searchByNameSubstring :: forall a. PackageIndex a -&gt; String -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#searchByNameSubstring"><span class="hs-identifier hs-var hs-var">searchByNameSubstring</span></a></span></span><span> </span><span id="local-6989586621679707272"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707272"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707271"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707271"><span class="hs-identifier hs-var">searchterm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-531"></span><span>  </span><span class="annot"><span class="annottext">PackageIndex a -&gt; (String -&gt; Bool) -&gt; [a]
forall a. PackageIndex a -&gt; (String -&gt; Bool) -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#searchWithPredicate"><span class="hs-identifier hs-var">searchWithPredicate</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707272"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="hs-special">(</span><span class="hs-glyph">\</span><span id="local-6989586621679707270"><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707270"><span class="hs-identifier hs-var">n</span></a></span></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707269"><span class="hs-identifier hs-var">lsearchterm</span></a></span><span> </span><span class="annot"><span class="annottext">String -&gt; String -&gt; Bool
forall a. Eq a =&gt; [a] -&gt; [a] -&gt; Bool
</span><a href="../../base/src/Data.OldList.html#isInfixOf"><span class="hs-operator hs-var">`isInfixOf`</span></a></span><span> </span><span class="annot"><span class="annottext">ShowS
</span><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-var">lowercase</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707270"><span class="hs-identifier hs-var">n</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-532"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679707269"><span class="annot"><span class="annottext">lsearchterm :: String
</span><a href="#local-6989586621679707269"><span class="hs-identifier hs-var hs-var">lsearchterm</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">ShowS
</span><a href="Distribution.Utils.Generic.html#lowercase"><span class="hs-identifier hs-var">lowercase</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><a href="#local-6989586621679707271"><span class="hs-identifier hs-var">searchterm</span></a></span><span>
</span><span id="line-533"></span><span>
</span><span id="line-534"></span><span class="hs-comment">-- | @since 3.4.0.0</span><span>
</span><span id="line-535"></span><span id="local-6989586621679707974"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#searchWithPredicate"><span class="hs-identifier hs-type">searchWithPredicate</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707974"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../base/src/GHC.Base.html#String"><span class="hs-identifier hs-type">String</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="hs-identifier hs-type">Bool</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707974"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-536"></span><span id="searchWithPredicate"><span class="annot"><span class="annottext">searchWithPredicate :: forall a. PackageIndex a -&gt; (String -&gt; Bool) -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#searchWithPredicate"><span class="hs-identifier hs-var hs-var">searchWithPredicate</span></a></span></span><span> </span><span id="local-6989586621679707267"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707267"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707266"><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="#local-6989586621679707266"><span class="hs-identifier hs-var">predicate</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-537"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707265"><span class="hs-identifier hs-var">pkg</span></a></span><span>
</span><span id="line-538"></span><span>  </span><span class="hs-comment">-- Don't match internal packages</span><span>
</span><span id="line-539"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span class="hs-special">(</span><span class="hs-special">(</span><span id="local-6989586621679707264"><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707264"><span class="hs-identifier hs-var">pname</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">LibraryName
</span><a href="Distribution.Types.LibraryName.html#LMainLibName"><span class="hs-identifier hs-var">LMainLibName</span></a></span><span class="hs-special">)</span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707263"><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707263"><span class="hs-identifier hs-var">pvers</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map (PackageName, LibraryName) (Map Version [a])
-&gt; [((PackageName, LibraryName), Map Version [a])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
forall a.
PackageIndex a -&gt; Map (PackageName, LibraryName) (Map Version [a])
</span><a href="Distribution.Simple.PackageIndex.html#packageIdIndex"><span class="hs-identifier hs-var hs-var">packageIdIndex</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707267"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-540"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">String -&gt; Bool
</span><a href="#local-6989586621679707266"><span class="hs-identifier hs-var">predicate</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageName -&gt; String
</span><a href="Distribution.Types.PackageName.html#unPackageName"><span class="hs-identifier hs-var">unPackageName</span></a></span><span> </span><span class="annot"><span class="annottext">PackageName
</span><a href="#local-6989586621679707264"><span class="hs-identifier hs-var">pname</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-541"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707262"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707262"><span class="hs-identifier hs-var">pkgs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map Version [a] -&gt; [[a]]
forall k a. Map k a -&gt; [a]
</span><a href="../../containers/src/Data.Map.Internal.html#elems"><span class="hs-identifier hs-var">Map.elems</span></a></span><span> </span><span class="annot"><span class="annottext">Map Version [a]
</span><a href="#local-6989586621679707263"><span class="hs-identifier hs-var">pvers</span></a></span><span>
</span><span id="line-542"></span><span>  </span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707265"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707265"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707262"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-543"></span><span>
</span><span id="line-544"></span><span class="hs-comment">--</span><span>
</span><span id="line-545"></span><span class="hs-comment">-- * Special queries</span><span>
</span><span id="line-546"></span><span class="hs-comment">--</span><span>
</span><span id="line-547"></span><span>
</span><span id="line-548"></span><span class="hs-comment">-- None of the stuff below depends on the internal representation of the index.</span><span>
</span><span id="line-549"></span><span class="hs-comment">--</span><span>
</span><span id="line-550"></span><span>
</span><span id="line-551"></span><span class="hs-comment">-- | Find if there are any cycles in the dependency graph. If there are no</span><span>
</span><span id="line-552"></span><span class="hs-comment">-- cycles the result is @[]@.</span><span>
</span><span id="line-553"></span><span class="hs-comment">--</span><span>
</span><span id="line-554"></span><span class="hs-comment">-- This actually computes the strongly connected components. So it gives us a</span><span>
</span><span id="line-555"></span><span class="hs-comment">-- list of groups of packages where within each group they all depend on each</span><span>
</span><span id="line-556"></span><span class="hs-comment">-- other, directly or indirectly.</span><span>
</span><span id="line-557"></span><span class="hs-comment">--</span><span>
</span><span id="line-558"></span><span id="local-6989586621679707971"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyCycles"><span class="hs-identifier hs-type">dependencyCycles</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707971"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707971"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707971"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span><span class="hs-special">]</span></span><span>
</span><span id="line-559"></span><span id="dependencyCycles"><span class="annot"><span class="annottext">dependencyCycles :: forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [[a]]
</span><a href="Distribution.Simple.PackageIndex.html#dependencyCycles"><span class="hs-identifier hs-var hs-var">dependencyCycles</span></a></span></span><span> </span><span id="local-6989586621679707257"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707257"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-560"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707256"><span class="hs-identifier hs-var">vs</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#CyclicSCC"><span class="hs-identifier hs-type">Graph.CyclicSCC</span></a></span><span> </span><span id="local-6989586621679707256"><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707256"><span class="hs-identifier hs-var">vs</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[(a, UnitId, [UnitId])] -&gt; [SCC a]
forall key node. Ord key =&gt; [(node, key, [key])] -&gt; [SCC node]
</span><a href="../../containers/src/Data.Graph.html#stronglyConnComp"><span class="hs-identifier hs-var">Graph.stronglyConnComp</span></a></span><span> </span><span class="annot"><span class="annottext">[(a, UnitId, [UnitId])]
</span><a href="#local-6989586621679707253"><span class="hs-identifier hs-var">adjacencyList</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-561"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-562"></span><span>    </span><span id="local-6989586621679707253"><span class="annot"><span class="annottext">adjacencyList :: [(a, UnitId, [UnitId])]
</span><a href="#local-6989586621679707253"><span class="hs-identifier hs-var hs-var">adjacencyList</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707250"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707250"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">a -&gt; [UnitId]
forall pkg. PackageInstalled pkg =&gt; pkg -&gt; [UnitId]
</span><a href="Distribution.Package.html#installedDepends"><span class="hs-identifier hs-var">installedDepends</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707250"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-563"></span><span>                    </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707250"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707250"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; [a]
forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var">allPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707257"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-564"></span><span>
</span><span id="line-565"></span><span>
</span><span id="line-566"></span><span class="hs-comment">-- | All packages that have immediate dependencies that are not in the index.</span><span>
</span><span id="line-567"></span><span class="hs-comment">--</span><span>
</span><span id="line-568"></span><span class="hs-comment">-- Returns such packages along with the dependencies that they're missing.</span><span>
</span><span id="line-569"></span><span class="hs-comment">--</span><span>
</span><span id="line-570"></span><span id="local-6989586621679707965"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#brokenPackages"><span class="hs-identifier hs-type">brokenPackages</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707965"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707965"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-571"></span><span>               </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="#local-6989586621679707965"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span></span><span>
</span><span id="line-572"></span><span id="brokenPackages"><span class="annot"><span class="annottext">brokenPackages :: forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [(a, [UnitId])]
</span><a href="Distribution.Simple.PackageIndex.html#brokenPackages"><span class="hs-identifier hs-var hs-var">brokenPackages</span></a></span></span><span> </span><span id="local-6989586621679707246"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707246"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-573"></span><span>  </span><span class="hs-special">[</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707245"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707244"><span class="hs-identifier hs-var">missing</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-574"></span><span>  </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707245"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707245"><span class="hs-identifier hs-var">pkg</span></a></span></span><span>  </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; [a]
forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var">allPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707246"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-575"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707244"><span class="annot"><span class="annottext">missing :: [UnitId]
</span><a href="#local-6989586621679707244"><span class="hs-identifier hs-var hs-var">missing</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707242"><span class="hs-identifier hs-var">pkg'</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707242"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707242"><span class="hs-identifier hs-var">pkg'</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">a -&gt; [UnitId]
forall pkg. PackageInstalled pkg =&gt; pkg -&gt; [UnitId]
</span><a href="Distribution.Package.html#installedDepends"><span class="hs-identifier hs-var">installedDepends</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707245"><span class="hs-identifier hs-var">pkg</span></a></span><span>
</span><span id="line-576"></span><span>                         </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Maybe a -&gt; Bool
forall a. Maybe a -&gt; Bool
</span><a href="../../base/src/Data.Maybe.html#isNothing"><span class="hs-identifier hs-var">isNothing</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; UnitId -&gt; Maybe a
forall a. PackageIndex a -&gt; UnitId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-var">lookupUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707246"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707242"><span class="hs-identifier hs-var">pkg'</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-577"></span><span>  </span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Bool -&gt; Bool
</span><span class="hs-identifier hs-var">not</span></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[UnitId] -&gt; Bool
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Bool
</span><a href="../../base/src/Data.Foldable.html#null"><span class="hs-identifier hs-var">null</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707244"><span class="hs-identifier hs-var">missing</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-578"></span><span>
</span><span id="line-579"></span><span class="hs-comment">-- | Tries to take the transitive closure of the package dependencies.</span><span>
</span><span id="line-580"></span><span class="hs-comment">--</span><span>
</span><span id="line-581"></span><span class="hs-comment">-- If the transitive closure is complete then it returns that subset of the</span><span>
</span><span id="line-582"></span><span class="hs-comment">-- index. Otherwise it returns the broken packages as in 'brokenPackages'.</span><span>
</span><span id="line-583"></span><span class="hs-comment">--</span><span>
</span><span id="line-584"></span><span class="hs-comment">-- * Note that if the result is @Right []@ it is because at least one of</span><span>
</span><span id="line-585"></span><span class="hs-comment">-- the original given 'PackageId's do not occur in the index.</span><span>
</span><span id="line-586"></span><span class="hs-comment">--</span><span>
</span><span id="line-587"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyClosure"><span class="hs-identifier hs-type">dependencyClosure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-588"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-589"></span><span>                  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/Data.Either.html#Either"><span class="hs-identifier hs-type">Either</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-590"></span><span>                            </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-591"></span><span id="dependencyClosure"><span class="annot"><span class="annottext">dependencyClosure :: PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; Either
     (PackageIndex InstalledPackageInfo)
     [(InstalledPackageInfo, [UnitId])]
</span><a href="Distribution.Simple.PackageIndex.html#dependencyClosure"><span class="hs-identifier hs-var hs-var">dependencyClosure</span></a></span></span><span> </span><span id="local-6989586621679707240"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707240"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span id="local-6989586621679707239"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707239"><span class="hs-identifier hs-var">pkgids0</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; [UnitId]
-&gt; (PackageIndex InstalledPackageInfo, [UnitId])
</span><a href="#local-6989586621679707238"><span class="hs-identifier hs-var">closure</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
forall a. Monoid a =&gt; a
</span><a href="../../base/src/GHC.Base.html#mempty"><span class="hs-identifier hs-var">mempty</span></a></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707239"><span class="hs-identifier hs-var">pkgids0</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-592"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679707237"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707237"><span class="hs-identifier hs-var">completed</span></a></span></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; Either
     (PackageIndex InstalledPackageInfo)
     [(InstalledPackageInfo, [UnitId])]
forall a b. a -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Left"><span class="hs-identifier hs-var">Left</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707237"><span class="hs-identifier hs-var">completed</span></a></span><span>
</span><span id="line-593"></span><span>  </span><span class="hs-special">(</span><span id="local-6989586621679707236"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707236"><span class="hs-identifier hs-var">completed</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">[(InstalledPackageInfo, [UnitId])]
-&gt; Either
     (PackageIndex InstalledPackageInfo)
     [(InstalledPackageInfo, [UnitId])]
forall a b. b -&gt; Either a b
</span><a href="../../base/src/Data.Either.html#Right"><span class="hs-identifier hs-var">Right</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; [(InstalledPackageInfo, [UnitId])]
forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [(a, [UnitId])]
</span><a href="Distribution.Simple.PackageIndex.html#brokenPackages"><span class="hs-identifier hs-var">brokenPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707236"><span class="hs-identifier hs-var">completed</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-594"></span><span> </span><span class="hs-keyword">where</span><span>
</span><span id="line-595"></span><span>    </span><span id="local-6989586621679707238"><span class="annot"><span class="annottext">closure :: PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; [UnitId]
-&gt; (PackageIndex InstalledPackageInfo, [UnitId])
</span><a href="#local-6989586621679707238"><span class="hs-identifier hs-var hs-var">closure</span></a></span></span><span> </span><span id="local-6989586621679707234"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707234"><span class="hs-identifier hs-var">completed</span></a></span></span><span> </span><span id="local-6989586621679707233"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707233"><span class="hs-identifier hs-var">failed</span></a></span></span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707234"><span class="hs-identifier hs-var">completed</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707233"><span class="hs-identifier hs-var">failed</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-596"></span><span>    </span><span class="annot"><a href="#local-6989586621679707238"><span class="hs-identifier hs-var">closure</span></a></span><span> </span><span id="local-6989586621679707232"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707232"><span class="hs-identifier hs-var">completed</span></a></span></span><span> </span><span id="local-6989586621679707231"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707231"><span class="hs-identifier hs-var">failed</span></a></span></span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707230"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707230"><span class="hs-identifier hs-var">pkgid</span></a></span></span><span class="annot"><span class="hs-glyph hs-type">:</span></span><span id="local-6989586621679707229"><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707229"><span class="hs-identifier hs-var">pkgids</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; UnitId -&gt; Maybe InstalledPackageInfo
forall a. PackageIndex a -&gt; UnitId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-var">lookupUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707240"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707230"><span class="hs-identifier hs-var">pkgid</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-597"></span><span>      </span><span class="annot"><span class="annottext">Maybe InstalledPackageInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; [UnitId]
-&gt; (PackageIndex InstalledPackageInfo, [UnitId])
</span><a href="#local-6989586621679707238"><span class="hs-identifier hs-var">closure</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707232"><span class="hs-identifier hs-var">completed</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707230"><span class="hs-identifier hs-var">pkgid</span></a></span><span class="annot"><span class="annottext">UnitId -&gt; [UnitId] -&gt; [UnitId]
forall a. a -&gt; [a] -&gt; [a]
</span><span class="hs-glyph hs-var">:</span></span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707231"><span class="hs-identifier hs-var">failed</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707229"><span class="hs-identifier hs-var">pkgids</span></a></span><span>
</span><span id="line-598"></span><span>      </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707228"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707228"><span class="hs-identifier hs-var">pkg</span></a></span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; UnitId -&gt; Maybe InstalledPackageInfo
forall a. PackageIndex a -&gt; UnitId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-var">lookupUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707232"><span class="hs-identifier hs-var">completed</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707228"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-599"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><span class="hs-identifier">_</span></span><span>  </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; [UnitId]
-&gt; (PackageIndex InstalledPackageInfo, [UnitId])
</span><a href="#local-6989586621679707238"><span class="hs-identifier hs-var">closure</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707232"><span class="hs-identifier hs-var">completed</span></a></span><span>  </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707231"><span class="hs-identifier hs-var">failed</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707229"><span class="hs-identifier hs-var">pkgids</span></a></span><span>
</span><span id="line-600"></span><span>        </span><span class="annot"><span class="annottext">Maybe InstalledPackageInfo
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; [UnitId]
-&gt; [UnitId]
-&gt; (PackageIndex InstalledPackageInfo, [UnitId])
</span><a href="#local-6989586621679707238"><span class="hs-identifier hs-var">closure</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707227"><span class="hs-identifier hs-var">completed'</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707231"><span class="hs-identifier hs-var">failed</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707226"><span class="hs-identifier hs-var">pkgids'</span></a></span><span>
</span><span id="line-601"></span><span>          </span><span class="hs-keyword">where</span><span> </span><span id="local-6989586621679707227"><span class="annot"><span class="annottext">completed' :: PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707227"><span class="hs-identifier hs-var hs-var">completed'</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
-&gt; PackageIndex InstalledPackageInfo
</span><a href="Distribution.Simple.PackageIndex.html#insert"><span class="hs-identifier hs-var">insert</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707228"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707232"><span class="hs-identifier hs-var">completed</span></a></span><span>
</span><span id="line-602"></span><span>                </span><span id="local-6989586621679707226"><span class="annot"><span class="annottext">pkgids' :: [UnitId]
</span><a href="#local-6989586621679707226"><span class="hs-identifier hs-var hs-var">pkgids'</span></a></span></span><span>    </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; [UnitId]
forall pkg. PackageInstalled pkg =&gt; pkg -&gt; [UnitId]
</span><a href="Distribution.Package.html#installedDepends"><span class="hs-identifier hs-var">installedDepends</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707228"><span class="hs-identifier hs-var">pkg</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId] -&gt; [UnitId] -&gt; [UnitId]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">++</span></a></span><span> </span><span class="annot"><span class="annottext">[UnitId]
</span><a href="#local-6989586621679707229"><span class="hs-identifier hs-var">pkgids</span></a></span><span>
</span><span id="line-603"></span><span>
</span><span id="line-604"></span><span class="hs-comment">-- | Takes the transitive closure of the packages reverse dependencies.</span><span>
</span><span id="line-605"></span><span class="hs-comment">--</span><span>
</span><span id="line-606"></span><span class="hs-comment">-- * The given 'PackageId's must be in the index.</span><span>
</span><span id="line-607"></span><span class="hs-comment">--</span><span>
</span><span id="line-608"></span><span id="local-6989586621679707960"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#reverseDependencyClosure"><span class="hs-identifier hs-type">reverseDependencyClosure</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707960"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707960"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-609"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-610"></span><span>                         </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707960"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-611"></span><span id="reverseDependencyClosure"><span class="annot"><span class="annottext">reverseDependencyClosure :: forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [UnitId] -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#reverseDependencyClosure"><span class="hs-identifier hs-var hs-var">reverseDependencyClosure</span></a></span></span><span> </span><span id="local-6989586621679707222"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707222"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-612"></span><span>    </span><span class="annot"><span class="annottext">(Int -&gt; a) -&gt; [Int] -&gt; [a]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707221"><span class="hs-identifier hs-var">vertexToPkg</span></a></span><span>
</span><span id="line-613"></span><span>  </span><span class="annot"><span class="annottext">([Int] -&gt; [a]) -&gt; ([UnitId] -&gt; [Int]) -&gt; [UnitId] -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(Tree Int -&gt; [Int]) -&gt; [Tree Int] -&gt; [Int]
forall (t :: * -&gt; *) a b. Foldable t =&gt; (a -&gt; [b]) -&gt; t a -&gt; [b]
</span><a href="../../base/src/Data.Foldable.html#concatMap"><span class="hs-identifier hs-var">concatMap</span></a></span><span> </span><span class="annot"><span class="annottext">Tree Int -&gt; [Int]
forall a. Tree a -&gt; [a]
</span><a href="../../containers/src/Data.Tree.html#flatten"><span class="hs-identifier hs-var">Tree.flatten</span></a></span><span>
</span><span id="line-614"></span><span>  </span><span class="annot"><span class="annottext">([Tree Int] -&gt; [Int])
-&gt; ([UnitId] -&gt; [Tree Int]) -&gt; [UnitId] -&gt; [Int]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Graph -&gt; [Int] -&gt; [Tree Int]
</span><a href="../../containers/src/Data.Graph.html#dfs"><span class="hs-identifier hs-var">Graph.dfs</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707217"><span class="hs-identifier hs-var">reverseDepGraph</span></a></span><span>
</span><span id="line-615"></span><span>  </span><span class="annot"><span class="annottext">([Int] -&gt; [Tree Int])
-&gt; ([UnitId] -&gt; [Int]) -&gt; [UnitId] -&gt; [Tree Int]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">(UnitId -&gt; Int) -&gt; [UnitId] -&gt; [Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int -&gt; Maybe Int -&gt; Int
forall a. a -&gt; Maybe a -&gt; a
</span><a href="../../base/src/Data.Maybe.html#fromMaybe"><span class="hs-identifier hs-var">fromMaybe</span></a></span><span> </span><span class="annot"><span class="annottext">Int
forall {a}. a
</span><a href="#local-6989586621679707215"><span class="hs-identifier hs-var">noSuchPkgId</span></a></span><span> </span><span class="annot"><span class="annottext">(Maybe Int -&gt; Int) -&gt; (UnitId -&gt; Maybe Int) -&gt; UnitId -&gt; Int
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><a href="#local-6989586621679707214"><span class="hs-identifier hs-var">pkgIdToVertex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-616"></span><span>
</span><span id="line-617"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-618"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679707212"><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707212"><span class="hs-identifier hs-var">depGraph</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707221"><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707221"><span class="hs-identifier hs-var">vertexToPkg</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707214"><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><a href="#local-6989586621679707214"><span class="hs-identifier hs-var">pkgIdToVertex</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
forall a.
PackageInstalled a =&gt;
PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
</span><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier hs-var">dependencyGraph</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707222"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-619"></span><span>    </span><span id="local-6989586621679707217"><span class="annot"><span class="annottext">reverseDepGraph :: Graph
</span><a href="#local-6989586621679707217"><span class="hs-identifier hs-var hs-var">reverseDepGraph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Graph -&gt; Graph
</span><a href="../../containers/src/Data.Graph.html#transposeG"><span class="hs-identifier hs-var">Graph.transposeG</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707212"><span class="hs-identifier hs-var">depGraph</span></a></span><span>
</span><span id="line-620"></span><span>    </span><span id="local-6989586621679707215"><span class="annot"><span class="annottext">noSuchPkgId :: a
</span><a href="#local-6989586621679707215"><span class="hs-identifier hs-var hs-var">noSuchPkgId</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">String -&gt; a
forall a. HasCallStack =&gt; String -&gt; a
</span><a href="../../base/src/GHC.Err.html#error"><span class="hs-identifier hs-var">error</span></a></span><span> </span><span class="annot"><span class="annottext">String
</span><span class="hs-string">&quot;reverseDependencyClosure: package is not in the graph&quot;</span></span><span>
</span><span id="line-621"></span><span>
</span><span id="line-622"></span><span id="local-6989586621679707949"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#topologicalOrder"><span class="hs-identifier hs-type">topologicalOrder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707949"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707949"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707949"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-623"></span><span id="topologicalOrder"><span class="annot"><span class="annottext">topologicalOrder :: forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#topologicalOrder"><span class="hs-identifier hs-var hs-var">topologicalOrder</span></a></span></span><span> </span><span id="local-6989586621679707207"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707207"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; a) -&gt; [Int] -&gt; [a]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707206"><span class="hs-identifier hs-var">toPkgId</span></a></span><span>
</span><span id="line-624"></span><span>                       </span><span class="annot"><span class="annottext">([Int] -&gt; [a]) -&gt; (Graph -&gt; [Int]) -&gt; Graph -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Graph -&gt; [Int]
</span><a href="../../containers/src/Data.Graph.html#topSort"><span class="hs-identifier hs-var">Graph.topSort</span></a></span><span>
</span><span id="line-625"></span><span>                       </span><span class="annot"><span class="annottext">(Graph -&gt; [a]) -&gt; Graph -&gt; [a]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707204"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-626"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707204"><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707204"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707206"><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707206"><span class="hs-identifier hs-var">toPkgId</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
forall a.
PackageInstalled a =&gt;
PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
</span><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier hs-var">dependencyGraph</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707207"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-627"></span><span>
</span><span id="line-628"></span><span id="local-6989586621679707202"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#reverseTopologicalOrder"><span class="hs-identifier hs-type">reverseTopologicalOrder</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707202"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707202"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="annot"><a href="#local-6989586621679707202"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">]</span></span><span>
</span><span id="line-629"></span><span id="reverseTopologicalOrder"><span class="annot"><span class="annottext">reverseTopologicalOrder :: forall a. PackageInstalled a =&gt; PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#reverseTopologicalOrder"><span class="hs-identifier hs-var hs-var">reverseTopologicalOrder</span></a></span></span><span> </span><span id="local-6989586621679707200"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707200"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int -&gt; a) -&gt; [Int] -&gt; [a]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707199"><span class="hs-identifier hs-var">toPkgId</span></a></span><span>
</span><span id="line-630"></span><span>                              </span><span class="annot"><span class="annottext">([Int] -&gt; [a]) -&gt; (Graph -&gt; [Int]) -&gt; Graph -&gt; [a]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Graph -&gt; [Int]
</span><a href="../../containers/src/Data.Graph.html#topSort"><span class="hs-identifier hs-var">Graph.topSort</span></a></span><span>
</span><span id="line-631"></span><span>                              </span><span class="annot"><span class="annottext">(Graph -&gt; [Int]) -&gt; (Graph -&gt; Graph) -&gt; Graph -&gt; [Int]
forall b c a. (b -&gt; c) -&gt; (a -&gt; b) -&gt; a -&gt; c
</span><a href="../../base/src/GHC.Base.html#."><span class="hs-operator hs-var">.</span></a></span><span> </span><span class="annot"><span class="annottext">Graph -&gt; Graph
</span><a href="../../containers/src/Data.Graph.html#transposeG"><span class="hs-identifier hs-var">Graph.transposeG</span></a></span><span>
</span><span id="line-632"></span><span>                              </span><span class="annot"><span class="annottext">(Graph -&gt; [a]) -&gt; Graph -&gt; [a]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707198"><span class="hs-identifier hs-var">graph</span></a></span><span>
</span><span id="line-633"></span><span>  </span><span class="hs-keyword">where</span><span> </span><span class="hs-special">(</span><span id="local-6989586621679707198"><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707198"><span class="hs-identifier hs-var">graph</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707199"><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707199"><span class="hs-identifier hs-var">toPkgId</span></a></span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
forall a.
PackageInstalled a =&gt;
PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
</span><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier hs-var">dependencyGraph</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707200"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-634"></span><span>
</span><span id="line-635"></span><span class="hs-comment">-- | Builds a graph of the package dependencies.</span><span>
</span><span id="line-636"></span><span class="hs-comment">--</span><span>
</span><span id="line-637"></span><span class="hs-comment">-- Dependencies on other packages that are not in the index are discarded.</span><span>
</span><span id="line-638"></span><span class="hs-comment">-- You can check if there are any such dependencies with 'brokenPackages'.</span><span>
</span><span id="line-639"></span><span class="hs-comment">--</span><span>
</span><span id="line-640"></span><span id="local-6989586621679707950"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier hs-type">dependencyGraph</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Package.html#PackageInstalled"><span class="hs-identifier hs-type">PackageInstalled</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707950"><span class="hs-identifier hs-type">a</span></a></span><span> </span><span class="hs-glyph">=&gt;</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#PackageIndex"><span class="hs-identifier hs-type">PackageIndex</span></a></span><span> </span><span class="annot"><a href="#local-6989586621679707950"><span class="hs-identifier hs-type">a</span></a></span><span>
</span><span id="line-641"></span><span>                </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Graph.html#Graph"><span class="hs-identifier hs-type">Graph.Graph</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-642"></span><span>                    </span><span class="annot"><a href="../../containers/src/Data.Graph.html#Vertex"><span class="hs-identifier hs-type">Graph.Vertex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="#local-6989586621679707950"><span class="hs-identifier hs-type">a</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-643"></span><span>                    </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Maybe"><span class="hs-identifier hs-type">Maybe</span></a></span><span> </span><span class="annot"><a href="../../containers/src/Data.Graph.html#Vertex"><span class="hs-identifier hs-type">Graph.Vertex</span></a></span><span class="hs-special">)</span></span><span>
</span><span id="line-644"></span><span id="dependencyGraph"><span class="annot"><span class="annottext">dependencyGraph :: forall a.
PackageInstalled a =&gt;
PackageIndex a -&gt; (Graph, Int -&gt; a, UnitId -&gt; Maybe Int)
</span><a href="Distribution.Simple.PackageIndex.html#dependencyGraph"><span class="hs-identifier hs-var hs-var">dependencyGraph</span></a></span></span><span> </span><span id="local-6989586621679707192"><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707192"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Graph
</span><a href="#local-6989586621679707191"><span class="hs-identifier hs-var">graph</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int -&gt; a
</span><a href="#local-6989586621679707190"><span class="hs-identifier hs-var">vertex_to_pkg</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><a href="#local-6989586621679707189"><span class="hs-identifier hs-var">id_to_vertex</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-645"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-646"></span><span>    </span><span id="local-6989586621679707191"><span class="annot"><span class="annottext">graph :: Graph
</span><a href="#local-6989586621679707191"><span class="hs-identifier hs-var hs-var">graph</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, Int) -&gt; [[Int]] -&gt; Graph
forall i e. Ix i =&gt; (i, i) -&gt; [e] -&gt; Array i e
</span><a href="../../base/src/GHC.Arr.html#listArray"><span class="hs-identifier hs-var">Array.listArray</span></a></span><span> </span><span class="annot"><span class="annottext">(Int, Int)
</span><a href="#local-6989586621679707184"><span class="hs-identifier hs-var">bounds</span></a></span><span>
</span><span id="line-647"></span><span>              </span><span class="hs-special">[</span><span> </span><span class="hs-special">[</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679707183"><span class="hs-identifier hs-var">v</span></a></span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707183"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679707183"><span class="hs-identifier hs-var">v</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">(UnitId -&gt; Maybe Int) -&gt; [UnitId] -&gt; [Maybe Int]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Maybe Int
</span><a href="#local-6989586621679707189"><span class="hs-identifier hs-var">id_to_vertex</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">a -&gt; [UnitId]
forall pkg. PackageInstalled pkg =&gt; pkg -&gt; [UnitId]
</span><a href="Distribution.Package.html#installedDepends"><span class="hs-identifier hs-var">installedDepends</span></a></span><span> </span><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707182"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-648"></span><span>              </span><span class="hs-glyph">|</span><span> </span><span id="local-6989586621679707182"><span class="annot"><span class="annottext">a
</span><a href="#local-6989586621679707182"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707181"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="hs-special">]</span><span>
</span><span id="line-649"></span><span>
</span><span id="line-650"></span><span>    </span><span id="local-6989586621679707181"><span class="annot"><span class="annottext">pkgs :: [a]
</span><a href="#local-6989586621679707181"><span class="hs-identifier hs-var hs-var">pkgs</span></a></span></span><span>             </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
forall a. (a -&gt; a -&gt; Ordering) -&gt; [a] -&gt; [a]
</span><a href="../../base/src/Data.OldList.html#sortBy"><span class="hs-identifier hs-var">sortBy</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; PackageId) -&gt; a -&gt; a -&gt; Ordering
forall a b. Ord a =&gt; (b -&gt; a) -&gt; b -&gt; b -&gt; Ordering
</span><a href="../../base/src/Data.Ord.html#comparing"><span class="hs-identifier hs-var">comparing</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; PackageId
forall pkg. Package pkg =&gt; pkg -&gt; PackageId
</span><a href="Distribution.Package.html#packageId"><span class="hs-identifier hs-var">packageId</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">PackageIndex a -&gt; [a]
forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var">allPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex a
</span><a href="#local-6989586621679707192"><span class="hs-identifier hs-var">index</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-651"></span><span>    </span><span id="local-6989586621679707173"><span class="annot"><span class="annottext">vertices :: [(UnitId, Int)]
</span><a href="#local-6989586621679707173"><span class="hs-identifier hs-var hs-var">vertices</span></a></span></span><span>         </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[UnitId] -&gt; [Int] -&gt; [(UnitId, Int)]
forall a b. [a] -&gt; [b] -&gt; [(a, b)]
</span><a href="../../base/src/GHC.List.html#zip"><span class="hs-identifier hs-var">zip</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(a -&gt; UnitId) -&gt; [a] -&gt; [UnitId]
forall a b. (a -&gt; b) -&gt; [a] -&gt; [b]
</span><a href="../../base/src/GHC.Base.html#map"><span class="hs-identifier hs-var">map</span></a></span><span> </span><span class="annot"><span class="annottext">a -&gt; UnitId
forall pkg. HasUnitId pkg =&gt; pkg -&gt; UnitId
</span><a href="Distribution.Package.html#installedUnitId"><span class="hs-identifier hs-var">installedUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707181"><span class="hs-identifier hs-var">pkgs</span></a></span><span class="hs-special">)</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-glyph">..</span><span class="hs-special">]</span><span>
</span><span id="line-652"></span><span>    </span><span id="local-6989586621679707171"><span class="annot"><span class="annottext">vertex_map :: Map UnitId Int
</span><a href="#local-6989586621679707171"><span class="hs-identifier hs-var hs-var">vertex_map</span></a></span></span><span>       </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[(UnitId, Int)] -&gt; Map UnitId Int
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span> </span><span class="annot"><span class="annottext">[(UnitId, Int)]
</span><a href="#local-6989586621679707173"><span class="hs-identifier hs-var">vertices</span></a></span><span>
</span><span id="line-653"></span><span>    </span><span id="local-6989586621679707189"><span class="annot"><span class="annottext">id_to_vertex :: UnitId -&gt; Maybe Int
</span><a href="#local-6989586621679707189"><span class="hs-identifier hs-var hs-var">id_to_vertex</span></a></span></span><span> </span><span id="local-6989586621679707169"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707169"><span class="hs-identifier hs-var">pid</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">UnitId -&gt; Map UnitId Int -&gt; Maybe Int
forall k a. Ord k =&gt; k -&gt; Map k a -&gt; Maybe a
</span><a href="../../containers/src/Data.Map.Internal.html#lookup"><span class="hs-identifier hs-var">Map.lookup</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707169"><span class="hs-identifier hs-var">pid</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId Int
</span><a href="#local-6989586621679707171"><span class="hs-identifier hs-var">vertex_map</span></a></span><span>
</span><span id="line-654"></span><span>
</span><span id="line-655"></span><span>    </span><span id="local-6989586621679707190"><span class="annot"><span class="annottext">vertex_to_pkg :: Int -&gt; a
</span><a href="#local-6989586621679707190"><span class="hs-identifier hs-var hs-var">vertex_to_pkg</span></a></span></span><span> </span><span id="local-6989586621679707167"><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679707167"><span class="hs-identifier hs-var">vertex</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Array Int a
</span><a href="#local-6989586621679707166"><span class="hs-identifier hs-var">pkgTable</span></a></span><span> </span><span class="annot"><span class="annottext">Array Int a -&gt; Int -&gt; a
forall i e. Ix i =&gt; Array i e -&gt; i -&gt; e
</span><a href="../../base/src/GHC.Arr.html#%21"><span class="hs-operator hs-var">!</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679707167"><span class="hs-identifier hs-var">vertex</span></a></span><span>
</span><span id="line-656"></span><span>
</span><span id="line-657"></span><span>    </span><span id="local-6989586621679707166"><span class="annot"><span class="annottext">pkgTable :: Array Int a
</span><a href="#local-6989586621679707166"><span class="hs-identifier hs-var hs-var">pkgTable</span></a></span></span><span>   </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Int, Int) -&gt; [a] -&gt; Array Int a
forall i e. Ix i =&gt; (i, i) -&gt; [e] -&gt; Array i e
</span><a href="../../base/src/GHC.Arr.html#listArray"><span class="hs-identifier hs-var">Array.listArray</span></a></span><span> </span><span class="annot"><span class="annottext">(Int, Int)
</span><a href="#local-6989586621679707184"><span class="hs-identifier hs-var">bounds</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707181"><span class="hs-identifier hs-var">pkgs</span></a></span><span>
</span><span id="line-658"></span><span>    </span><span id="local-6989586621679707161"><span class="annot"><span class="annottext">topBound :: Int
</span><a href="#local-6989586621679707161"><span class="hs-identifier hs-var hs-var">topBound</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">[a] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[a]
</span><a href="#local-6989586621679707181"><span class="hs-identifier hs-var">pkgs</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Int
forall a. Num a =&gt; a -&gt; a -&gt; a
</span><a href="../../base/src/GHC.Num.html#-"><span class="hs-glyph hs-var">-</span></a></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">1</span></span><span>
</span><span id="line-659"></span><span>    </span><span id="local-6989586621679707184"><span class="annot"><span class="annottext">bounds :: (Int, Int)
</span><a href="#local-6989586621679707184"><span class="hs-identifier hs-var hs-var">bounds</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">0</span></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">Int
</span><a href="#local-6989586621679707161"><span class="hs-identifier hs-var">topBound</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-660"></span><span>
</span><span id="line-661"></span><span class="hs-comment">-- | We maintain the invariant that, for any 'DepUniqueKey', there</span><span>
</span><span id="line-662"></span><span class="hs-comment">-- is only one instance of the package in our database.</span><span>
</span><span id="line-663"></span><span class="hs-keyword">type</span><span> </span><span id="DepUniqueKey"><span class="annot"><a href="Distribution.Simple.PackageIndex.html#DepUniqueKey"><span class="hs-identifier hs-var">DepUniqueKey</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.PackageName.html#PackageName"><span class="hs-identifier hs-type">PackageName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="Distribution.Types.LibraryName.html#LibraryName"><span class="hs-identifier hs-type">LibraryName</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-664"></span><span>
</span><span id="line-665"></span><span class="hs-comment">-- | Given a package index where we assume we want to use all the packages</span><span>
</span><span id="line-666"></span><span class="hs-comment">-- (use 'dependencyClosure' if you need to get such a index subset) find out</span><span>
</span><span id="line-667"></span><span class="hs-comment">-- if the dependencies within it use consistent versions of each package.</span><span>
</span><span id="line-668"></span><span class="hs-comment">-- Return all cases where multiple packages depend on different versions of</span><span>
</span><span id="line-669"></span><span class="hs-comment">-- some other package.</span><span>
</span><span id="line-670"></span><span class="hs-comment">--</span><span>
</span><span id="line-671"></span><span class="hs-comment">-- Each element in the result is a package name along with the packages that</span><span>
</span><span id="line-672"></span><span class="hs-comment">-- depend on it and the versions they require. These are guaranteed to be</span><span>
</span><span id="line-673"></span><span class="hs-comment">-- distinct.</span><span>
</span><span id="line-674"></span><span class="hs-comment">--</span><span>
</span><span id="line-675"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#dependencyInconsistencies"><span class="hs-identifier hs-type">dependencyInconsistencies</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span>
</span><span id="line-676"></span><span>                             </span><span class="hs-comment">-- At DepUniqueKey...</span><span>
</span><span id="line-677"></span><span>                          </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#DepUniqueKey"><span class="hs-identifier hs-type">DepUniqueKey</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-678"></span><span>                               </span><span class="hs-comment">-- There were multiple packages (BAD!)</span><span>
</span><span id="line-679"></span><span>                               </span><span class="hs-special">[</span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-680"></span><span>                                 </span><span class="hs-comment">-- And here are the packages which</span><span>
</span><span id="line-681"></span><span>                                 </span><span class="hs-comment">-- immediately depended on it</span><span>
</span><span id="line-682"></span><span>                                 </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span class="hs-special">)</span><span class="hs-special">]</span><span>
</span><span id="line-683"></span><span id="dependencyInconsistencies"><span class="annot"><span class="annottext">dependencyInconsistencies :: PackageIndex InstalledPackageInfo
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     [(UnitId, [InstalledPackageInfo])])]
</span><a href="Distribution.Simple.PackageIndex.html#dependencyInconsistencies"><span class="hs-identifier hs-var hs-var">dependencyInconsistencies</span></a></span></span><span> </span><span id="local-6989586621679707158"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707158"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-684"></span><span>    </span><span class="hs-special">(</span><span id="local-6989586621679707157"><span class="annot"><span class="annottext">(PackageName, LibraryName, Map ModuleName OpenModule)
</span><a href="#local-6989586621679707157"><span class="hs-identifier hs-var">dep_key</span></a></span></span><span class="hs-special">,</span><span> </span><span id="local-6989586621679707156"><span class="annot"><span class="annottext">Map UnitId [InstalledPackageInfo]
</span><a href="#local-6989586621679707156"><span class="hs-identifier hs-var">insts_map</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">Map
  (PackageName, LibraryName, Map ModuleName OpenModule)
  (Map UnitId [InstalledPackageInfo])
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     Map UnitId [InstalledPackageInfo])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map
  (PackageName, LibraryName, Map ModuleName OpenModule)
  (Map UnitId [InstalledPackageInfo])
</span><a href="#local-6989586621679707155"><span class="hs-identifier hs-var">inverseIndex</span></a></span><span>
</span><span id="line-685"></span><span>    </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707154"><span class="annot"><span class="annottext">insts :: [(UnitId, [InstalledPackageInfo])]
</span><a href="#local-6989586621679707154"><span class="hs-identifier hs-var hs-var">insts</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">Map UnitId [InstalledPackageInfo]
-&gt; [(UnitId, [InstalledPackageInfo])]
forall k a. Map k a -&gt; [(k, a)]
</span><a href="../../containers/src/Data.Map.Internal.html#toList"><span class="hs-identifier hs-var">Map.toList</span></a></span><span> </span><span class="annot"><span class="annottext">Map UnitId [InstalledPackageInfo]
</span><a href="#local-6989586621679707156"><span class="hs-identifier hs-var">insts_map</span></a></span><span>
</span><span id="line-686"></span><span>    </span><span class="annot"><span class="annottext">Bool -&gt; [()]
forall (f :: * -&gt; *). Alternative f =&gt; Bool -&gt; f ()
</span><a href="../../base/src/Control.Monad.html#guard"><span class="hs-identifier hs-var">guard</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">[(UnitId, [InstalledPackageInfo])] -&gt; Int
forall (t :: * -&gt; *) a. Foldable t =&gt; t a -&gt; Int
</span><a href="../../base/src/Data.Foldable.html#length"><span class="hs-identifier hs-var">length</span></a></span><span> </span><span class="annot"><span class="annottext">[(UnitId, [InstalledPackageInfo])]
</span><a href="#local-6989586621679707154"><span class="hs-identifier hs-var">insts</span></a></span><span> </span><span class="annot"><span class="annottext">Int -&gt; Int -&gt; Bool
forall a. Ord a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">&gt;=</span></span><span> </span><span class="annot"><span class="annottext">Int
</span><span class="hs-number">2</span></span><span class="hs-special">)</span><span>
</span><span id="line-687"></span><span>    </span><span class="annot"><span class="annottext">((PackageName, LibraryName, Map ModuleName OpenModule),
 [(UnitId, [InstalledPackageInfo])])
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     [(UnitId, [InstalledPackageInfo])])]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName, LibraryName, Map ModuleName OpenModule)
</span><a href="#local-6989586621679707157"><span class="hs-identifier hs-var">dep_key</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">[(UnitId, [InstalledPackageInfo])]
</span><a href="#local-6989586621679707154"><span class="hs-identifier hs-var">insts</span></a></span><span class="hs-special">)</span><span>
</span><span id="line-688"></span><span>  </span><span class="hs-keyword">where</span><span>
</span><span id="line-689"></span><span>    </span><span class="annot"><a href="#local-6989586621679707155"><span class="hs-identifier hs-type">inverseIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#DepUniqueKey"><span class="hs-identifier hs-type">DepUniqueKey</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.Types.UnitId.html#UnitId"><span class="hs-identifier hs-type">UnitId</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-690"></span><span>    </span><span id="local-6989586621679707155"><span class="annot"><span class="annottext">inverseIndex :: Map
  (PackageName, LibraryName, Map ModuleName OpenModule)
  (Map UnitId [InstalledPackageInfo])
</span><a href="#local-6989586621679707155"><span class="hs-identifier hs-var hs-var">inverseIndex</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="annot"><span class="annottext">(Map UnitId [InstalledPackageInfo]
 -&gt; Map UnitId [InstalledPackageInfo]
 -&gt; Map UnitId [InstalledPackageInfo])
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     Map UnitId [InstalledPackageInfo])]
-&gt; Map
     (PackageName, LibraryName, Map ModuleName OpenModule)
     (Map UnitId [InstalledPackageInfo])
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromListWith"><span class="hs-identifier hs-var">Map.fromListWith</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">([InstalledPackageInfo]
 -&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; Map UnitId [InstalledPackageInfo]
-&gt; Map UnitId [InstalledPackageInfo]
-&gt; Map UnitId [InstalledPackageInfo]
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; Map k a -&gt; Map k a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#unionWith"><span class="hs-identifier hs-var">Map.unionWith</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span class="hs-special">)</span><span> </span><span class="annot"><span class="annottext">([((PackageName, LibraryName, Map ModuleName OpenModule),
   Map UnitId [InstalledPackageInfo])]
 -&gt; Map
      (PackageName, LibraryName, Map ModuleName OpenModule)
      (Map UnitId [InstalledPackageInfo]))
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     Map UnitId [InstalledPackageInfo])]
-&gt; Map
     (PackageName, LibraryName, Map ModuleName OpenModule)
     (Map UnitId [InstalledPackageInfo])
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-691"></span><span>        </span><span id="local-6989586621679707152"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707152"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo -&gt; [InstalledPackageInfo]
forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var">allPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707158"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-692"></span><span>        </span><span id="local-6989586621679707151"><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707151"><span class="hs-identifier hs-var">dep_ipid</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; [UnitId]
forall pkg. PackageInstalled pkg =&gt; pkg -&gt; [UnitId]
</span><a href="Distribution.Package.html#installedDepends"><span class="hs-identifier hs-var">installedDepends</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707152"><span class="hs-identifier hs-var">pkg</span></a></span><span>
</span><span id="line-693"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span id="local-6989586621679707150"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707150"><span class="hs-identifier hs-var">dep</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
-&gt; UnitId -&gt; Maybe InstalledPackageInfo
forall a. PackageIndex a -&gt; UnitId -&gt; Maybe a
</span><a href="Distribution.Simple.PackageIndex.html#lookupUnitId"><span class="hs-identifier hs-var">lookupUnitId</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707158"><span class="hs-identifier hs-var">index</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707151"><span class="hs-identifier hs-var">dep_ipid</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-694"></span><span>        </span><span class="hs-keyword">let</span><span> </span><span id="local-6989586621679707147"><span class="annot"><span class="annottext">dep_key :: (PackageName, LibraryName, Map ModuleName OpenModule)
</span><a href="#local-6989586621679707147"><span class="hs-identifier hs-var hs-var">dep_key</span></a></span></span><span> </span><span class="hs-glyph">=</span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; PackageName
forall pkg. Package pkg =&gt; pkg -&gt; PackageName
</span><a href="Distribution.Package.html#packageName"><span class="hs-identifier hs-var">packageName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707150"><span class="hs-identifier hs-var">dep</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; LibraryName
</span><a href="Distribution.Types.InstalledPackageInfo.html#sourceLibName"><span class="hs-identifier hs-var hs-var">IPI.sourceLibName</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707150"><span class="hs-identifier hs-var">dep</span></a></span><span class="hs-special">,</span><span>
</span><span id="line-695"></span><span>                       </span><span class="annot"><span class="annottext">[(ModuleName, OpenModule)] -&gt; Map ModuleName OpenModule
forall k a. Ord k =&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromList"><span class="hs-identifier hs-var">Map.fromList</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; [(ModuleName, OpenModule)]
</span><a href="Distribution.Types.InstalledPackageInfo.html#instantiatedWith"><span class="hs-identifier hs-var hs-var">IPI.instantiatedWith</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707150"><span class="hs-identifier hs-var">dep</span></a></span><span class="hs-special">)</span><span class="hs-special">)</span><span>
</span><span id="line-696"></span><span>        </span><span class="annot"><span class="annottext">((PackageName, LibraryName, Map ModuleName OpenModule),
 Map UnitId [InstalledPackageInfo])
-&gt; [((PackageName, LibraryName, Map ModuleName OpenModule),
     Map UnitId [InstalledPackageInfo])]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">(PackageName, LibraryName, Map ModuleName OpenModule)
</span><a href="#local-6989586621679707147"><span class="hs-identifier hs-var">dep_key</span></a></span><span class="hs-special">,</span><span> </span><span class="annot"><span class="annottext">UnitId
-&gt; [InstalledPackageInfo] -&gt; Map UnitId [InstalledPackageInfo]
forall k a. k -&gt; a -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#singleton"><span class="hs-identifier hs-var">Map.singleton</span></a></span><span> </span><span class="annot"><span class="annottext">UnitId
</span><a href="#local-6989586621679707151"><span class="hs-identifier hs-var">dep_ipid</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707152"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-697"></span><span>
</span><span id="line-698"></span><span class="hs-comment">-- | A rough approximation of GHC's module finder, takes a</span><span>
</span><span id="line-699"></span><span class="hs-comment">-- 'InstalledPackageIndex' and turns it into a map from module names to their</span><span>
</span><span id="line-700"></span><span class="hs-comment">-- source packages.  It's used to initialize the @build-deps@ field in @cabal</span><span>
</span><span id="line-701"></span><span class="hs-comment">-- init@.</span><span>
</span><span id="line-702"></span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#moduleNameIndex"><span class="hs-identifier hs-type">moduleNameIndex</span></a></span><span> </span><span class="hs-glyph">::</span><span> </span><span class="annot"><a href="Distribution.Simple.PackageIndex.html#InstalledPackageIndex"><span class="hs-identifier hs-type">InstalledPackageIndex</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><a href="../../containers/src/Data.Map.Internal.html#Map"><span class="hs-identifier hs-type">Map</span></a></span><span> </span><span class="annot"><a href="Distribution.ModuleName.html#ModuleName"><span class="hs-identifier hs-type">ModuleName</span></a></span><span> </span><span class="hs-special">[</span><span class="annot"><a href="Distribution.Types.InstalledPackageInfo.html#InstalledPackageInfo"><span class="hs-identifier hs-type">IPI.InstalledPackageInfo</span></a></span><span class="hs-special">]</span><span>
</span><span id="line-703"></span><span id="moduleNameIndex"><span class="annot"><span class="annottext">moduleNameIndex :: PackageIndex InstalledPackageInfo
-&gt; Map ModuleName [InstalledPackageInfo]
</span><a href="Distribution.Simple.PackageIndex.html#moduleNameIndex"><span class="hs-identifier hs-var hs-var">moduleNameIndex</span></a></span></span><span> </span><span id="local-6989586621679707146"><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707146"><span class="hs-identifier hs-var">index</span></a></span></span><span> </span><span class="hs-glyph">=</span><span>
</span><span id="line-704"></span><span>  </span><span class="annot"><span class="annottext">([InstalledPackageInfo]
 -&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo])
-&gt; [(ModuleName, [InstalledPackageInfo])]
-&gt; Map ModuleName [InstalledPackageInfo]
forall k a. Ord k =&gt; (a -&gt; a -&gt; a) -&gt; [(k, a)] -&gt; Map k a
</span><a href="../../containers/src/Data.Map.Strict.Internal.html#fromListWith"><span class="hs-identifier hs-var">Map.fromListWith</span></a></span><span> </span><span class="annot"><span class="annottext">[InstalledPackageInfo]
-&gt; [InstalledPackageInfo] -&gt; [InstalledPackageInfo]
forall a. [a] -&gt; [a] -&gt; [a]
</span><a href="../../base/src/GHC.Base.html#%2B%2B"><span class="hs-operator hs-var">(++)</span></a></span><span> </span><span class="annot"><span class="annottext">([(ModuleName, [InstalledPackageInfo])]
 -&gt; Map ModuleName [InstalledPackageInfo])
-&gt; [(ModuleName, [InstalledPackageInfo])]
-&gt; Map ModuleName [InstalledPackageInfo]
forall a b. (a -&gt; b) -&gt; a -&gt; b
</span><a href="../../base/src/GHC.Base.html#%24"><span class="hs-operator hs-var">$</span></a></span><span> </span><span class="hs-keyword">do</span><span>
</span><span id="line-705"></span><span>    </span><span id="local-6989586621679707145"><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707145"><span class="hs-identifier hs-var">pkg</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo -&gt; [InstalledPackageInfo]
forall a. PackageIndex a -&gt; [a]
</span><a href="Distribution.Simple.PackageIndex.html#allPackages"><span class="hs-identifier hs-var">allPackages</span></a></span><span> </span><span class="annot"><span class="annottext">PackageIndex InstalledPackageInfo
</span><a href="#local-6989586621679707146"><span class="hs-identifier hs-var">index</span></a></span><span>
</span><span id="line-706"></span><span>    </span><span class="annot"><a href="Distribution.Types.ExposedModule.html#ExposedModule"><span class="hs-identifier hs-type">IPI.ExposedModule</span></a></span><span> </span><span id="local-6989586621679707143"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707143"><span class="hs-identifier hs-var">m</span></a></span></span><span> </span><span id="local-6989586621679707142"><span class="annot"><span class="annottext">Maybe OpenModule
</span><a href="#local-6989586621679707142"><span class="hs-identifier hs-var">reexport</span></a></span></span><span> </span><span class="hs-glyph">&lt;-</span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo -&gt; [ExposedModule]
</span><a href="Distribution.Types.InstalledPackageInfo.html#exposedModules"><span class="hs-identifier hs-var hs-var">IPI.exposedModules</span></a></span><span> </span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707145"><span class="hs-identifier hs-var">pkg</span></a></span><span>
</span><span id="line-707"></span><span>    </span><span class="hs-keyword">case</span><span> </span><span class="annot"><span class="annottext">Maybe OpenModule
</span><a href="#local-6989586621679707142"><span class="hs-identifier hs-var">reexport</span></a></span><span> </span><span class="hs-keyword">of</span><span>
</span><span id="line-708"></span><span>        </span><span class="annot"><span class="annottext">Maybe OpenModule
</span><a href="../../base/src/GHC.Maybe.html#Nothing"><span class="hs-identifier hs-var">Nothing</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ModuleName, [InstalledPackageInfo])
-&gt; [(ModuleName, [InstalledPackageInfo])]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707143"><span class="hs-identifier hs-var">m</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707145"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-709"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenModuleVar"><span class="hs-identifier hs-type">OpenModuleVar</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><span class="hs-identifier">_</span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-710"></span><span>        </span><span class="annot"><a href="../../base/src/GHC.Maybe.html#Just"><span class="hs-identifier hs-type">Just</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><a href="Distribution.Backpack.html#OpenModule"><span class="hs-identifier hs-type">OpenModule</span></a></span><span> </span><span class="annot"><span class="annottext">OpenUnitId
</span><span class="hs-identifier">_</span></span><span> </span><span id="local-6989586621679707138"><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707138"><span class="hs-identifier hs-var">m'</span></a></span></span><span class="hs-special">)</span><span> </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707143"><span class="hs-identifier hs-var">m</span></a></span><span> </span><span class="annot"><span class="annottext">ModuleName -&gt; ModuleName -&gt; Bool
forall a. Eq a =&gt; a -&gt; a -&gt; Bool
</span><span class="hs-operator hs-var">==</span></span><span> </span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707138"><span class="hs-identifier hs-var">m'</span></a></span><span>   </span><span class="hs-glyph">-&gt;</span><span> </span><span class="hs-special">[</span><span class="hs-special">]</span><span>
</span><span id="line-711"></span><span>                                </span><span class="hs-glyph">|</span><span> </span><span class="annot"><span class="annottext">Bool
</span><a href="../../base/src/GHC.Base.html#otherwise"><span class="hs-identifier hs-var">otherwise</span></a></span><span> </span><span class="hs-glyph">-&gt;</span><span> </span><span class="annot"><span class="annottext">(ModuleName, [InstalledPackageInfo])
-&gt; [(ModuleName, [InstalledPackageInfo])]
forall (m :: * -&gt; *) a. Monad m =&gt; a -&gt; m a
</span><a href="../../base/src/GHC.Base.html#return"><span class="hs-identifier hs-var">return</span></a></span><span> </span><span class="hs-special">(</span><span class="annot"><span class="annottext">ModuleName
</span><a href="#local-6989586621679707138"><span class="hs-identifier hs-var">m'</span></a></span><span class="hs-special">,</span><span> </span><span class="hs-special">[</span><span class="annot"><span class="annottext">InstalledPackageInfo
</span><a href="#local-6989586621679707145"><span class="hs-identifier hs-var">pkg</span></a></span><span class="hs-special">]</span><span class="hs-special">)</span><span>
</span><span id="line-712"></span><span>        </span><span class="hs-comment">-- The heuristic is this: we want to prefer the original package</span><span>
</span><span id="line-713"></span><span>        </span><span class="hs-comment">-- which originally exported a module.  However, if a reexport</span><span>
</span><span id="line-714"></span><span>        </span><span class="hs-comment">-- also *renamed* the module (m /= m'), then we have to use the</span><span>
</span><span id="line-715"></span><span>        </span><span class="hs-comment">-- downstream package, since the upstream package has the wrong</span><span>
</span><span id="line-716"></span><span>        </span><span class="hs-comment">-- module name!</span><span>
</span><span id="line-717"></span></pre></body></html>